InChi library is not loaded in java application

User 2fe6170bd1

09-03-2007 10:13:10

Hi all,





I have seen a recent post (March, 7th) on InChi but I think it is not the same problem.





I have a java application:





Code:
1: JPanel panelViewer = (JPanel)getContentPane().getComponent(1);   


2: MViewPane viewer = (MViewPane)panelViewer.getComponent(0);


3: String molstr = viewer.getM(0, "mol");


4: Molecule molecule = viewer.getM(0);


5: byte[] sdf = molecule.toBinFormat("sdf");


6: System.load("C:/DLL/Prod/Structures/jchem/inchi.dll");


7: String molstr = molecule.toFormat("InChI");   






where 1:, 2:, etc. are line numbers





after executing line 7, I get:





Code:
java.lang.IllegalArgumentException: InChi library is not loaded.





   at chemaxon.struc.Molecule.toFormat(Molecule.java:829)








at line 6, if I type "inchi2.dll" an exception is raised: ok, so line 6 seems to "load" the inchi.dll





I am executing:





Code:
javaw.exe -ojvm -classpath c:\MyProjects\classes;c:\jchem3.1.5\jchem\lib;C:\jdev1012\jdbc\lib\ojdbc14.jar;c:\MyProjects\lib\jchem.jar;C:\jdev1012\jdev\lib\jdev-rt.jar;c:\MyProjects\lib\inchiexport.jar jchem.UpdateStructure 80000 JCHEMUSER JCHEMUSER






Any ideas?





Thanks in advance

ChemAxon 9c0afc9aaf

09-03-2007 12:00:59

Hi,





It seems the problem is with your classpath.





"c:\jchem3.1.5\jchem\lib" is included.


If I presume this refers to the jchem package, then it is not correct, because in the case of the CLASSPATH, the actual jar file (jchem.jar) should be listed, not the enclosing directory.





You also list "c:\MyProjects\lib\jchem.jar", but the problem here is that you probably copied only jchem.jar here, and not all the supporting files that are present in jchem's lib directory.





So I suggest to remove this latter reference to jchem jar, and alter the first reference to "c:\jchem3.1.5\jchem\lib\jchem.jar" instead.





The manifest file and the place of jchem.jar (or in the case of Marvin MarvinBeans.jar) helps to find the other libraries in the same directory.





You should not use System.load() to load InChI dll-s, our software should take care of this if the classpath is correctly set.





Best regards,





Szilard





PS: You may argue why do you get an exception if you manually load the dll yourself. I think it's because our software doesn't expect the possibility of this, it always tries to find the libraries as provided by ChemAxon.

User 2fe6170bd1

09-03-2007 14:06:16

Hi Szilard,





Thanks for your quick reply.





I have changed the classpath as you suggested:





Code:
javaw.exe -ojvm -classpath c:\MyProject\classes;C:\jdev1012\jdbc\lib\ojdbc14.jar;C:\jdev1012\jdev\lib\jdev-rt.jar;c:\jchem3.1.5\jchem\lib\jchem.jar jchem.UpdateStructure 80000 JCHEMUSER JCHEMUSER






the same code as before does not raise any exceptions but the resulting String is "" (whereas if instead of "inchi" I ask for "smiles:a-H", the string is not empty)





If I comment the "loadLibrary" line as you suggest, the result is the same.





Any ideas?





Thanks in advance

ChemAxon 0a9e2a55e1

10-03-2007 15:39:58

Hi,





I have tried your sample code, in most of the versions since jchem 3.1.5, but it worked properly. Normally InChI string is never "", this must raise an exception.





Does this exception occure with every molecule, or just a few of them?





Could you specify on which (Windows) platform which molecule caused the problem and send a java file that does not work properly.





Best Regards,





Peter





PS: In 3.1.5 the old inchi is included. It can only import InChI with full AuxInfo. If you use the InChI features I recommend the latest version, with our new inchi library, where AuxInfo is not needed to import.

User 2fe6170bd1

12-03-2007 11:34:01

Hi,





The following java file is a test case for InChi. The string is the Paracetamol's mol file.





Code:
package JChemMaint;





import chemaxon.struc.Molecule;


import chemaxon.formats.MolImporter;





public class InchiTest


{


  public InchiTest()


  {


  }





  /**


   *


   * @param args


   */


  public static void main(String[] args) throws chemaxon.formats.MolFormatException, java.io.IOException


  {


    InchiTest inchiTest = new InchiTest();


    String s =


"\n" +


"  Marvin  03090716332D\n" +


"\n" +


" 12 12  0  0  0  0            999 V2000\n" +


"    0.0645    0.3414    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"    0.0645   -0.4817    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"    0.7928    0.7435    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"   -1.3732    0.3414    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"   -0.6638   -0.9028    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"    1.5097    0.3300    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"   -1.3732   -0.4817    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"    2.2229    0.7284    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"    1.5097   -0.4969    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"   -2.0901   -0.8876    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"   -0.6638    0.7625    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"   -0.6685    1.5875    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +


"  1 11  1  0  0  0  0\n" +


"  1  2  2  0  0  0  0\n" +


"  1  3  1  0  0  0  0\n" +


" 11  4  2  0  0  0  0\n" +


"  2  5  1  0  0  0  0\n" +


"  3  6  1  0  0  0  0\n" +


"  4  7  1  0  0  0  0\n" +


"  6  8  1  0  0  0  0\n" +


"  6  9  2  0  0  0  0\n" +


"  7 10  1  0  0  0  0\n" +


"  5  7  2  0  0  0  0\n" +


" 11 12  1  0  0  0  0\n" +


"M  END" +


"\n";





    Molecule molecule = MolImporter.importMol(s); // Paracetamol


    String aux = molecule.toFormat("smiles:a-H");


    System.out.println("smiles:a-H");


    System.out.println("==========");


    System.out.print(aux);


    System.out.println("");


    System.out.println("");


    aux = molecule.toFormat("inchi");


    System.out.println("inchi");


    System.out.println("=====");


    System.out.print(aux);


    System.out.println("");


    System.out.println("");


    aux = molecule.toFormat("smiles:a-H");


    System.out.println("smiles:a-H");


    System.out.println("==========");


    System.out.print(aux);


    System.out.println("");


    System.out.println("");


  }


}






The output I get is:


Code:



smiles:a-H


==========


CC(=O)Nc1ccc(O)cc1C





inchi


=====





smiles:a-H


==========


CC(=O)Nc1ccc(O)cc1C






I have done the test using Jchem 3.2.3:





Code:
C:\jdev1012\jdk\bin\javaw.exe -ojvm -classpath C:\jdev1012\jdbc\lib\ojdbc14.jar;C:\jdev1012\jdev\lib\jdev-rt.jar;C:\Program Files\jchem3.2.3\jchem\lib\jchem.jar JChemMaint.InchiTest 80000 JCHEMUSER JCHEMUSER








perhaps should I explicity add more jars in the classfile?. If so, which ones?





Thanks in advance





Jordi

ChemAxon 0a9e2a55e1

12-03-2007 23:35:41

Hi,





I have tried your test case in JChem 3.2.3 and it worked.


I used the Java 1.4.2_05 and the following code (your sample code without the package):





javac -classpath "C:\Program Files\ChemAxon\JChem\lib\jchem.jar" InchiTest.java





java -classpath "C:\Program Files\ChemAxon\JChem\lib\jchem.jar" InchiTest





and it worked. Both smiles and InChI strings were displayed correctly.





I think the problem can be the java. Which java do you have? What is the "-ojvm" switch for javaw? (I could not run your code with javaw.)





Best Regards,





Peter

User 2fe6170bd1

13-03-2007 14:06:57

No luck. I have tried in a Command Window:





Code:
"C:\Program Files\j2sdk1.4.2_13\bin\javac.exe" -classpath "C:\Program Files\jchem3.2.3\jchem\lib\jchem.jar" InchiTest.java


"C:\Program Files\j2sdk1.4.2_13\bin\java.exe" -classpath "C:\Program Files\jchem3.2.3\jchem\lib\jchem.jar";. InchiTest






Unfortunately, no InChi data is displayed.


I am using Windows XP Professional SP2.





If it can help, one of my collegues told me that he downloaded Marvin Sketch for your website, installed it in his PC (windows platform) drew a molecule and then "save as inchi file" and the file was empty.





Any new ideas?





Thanks in advance

ChemAxon 0a9e2a55e1

14-03-2007 12:56:38

Hi,





I have tried several versions of JChem and java, including JChem 3.2.3 and j2sdk1.4.2_13, and both your code, and "save as inchi file" in Marvin Sketch worked correctly on all machines I have used.





If the JChem environment have been modified then reinstalling JChem may solve the problem.





Best Regards,





Peter