MolSearchExample.java does not compile

User 6288f3e087

11-04-2011 13:28:47

Hello:


I am trying to run the example MolSearchExample.java located in ~/Chemaxon/JChem5.2/examples/java/search and I have added to my CLASSPATH the following:



$ printenv CLASSPATH


/usr/share/java/mysql.jar:/home/roberto/ChemAxon/JChem5.2/lib/jchem.jar:/home/roberto/ChemAxon/JChem5.2/marvin/sjars/util.jar



though as some point CLASSPATH had most of the jar files on ~/Chemaxon/lib. When I try to compile, I get the next error:



$ javac MolSearchExample.java 


MolSearchExample.java:53: cannot find symbol


symbol  : variable Util


location: class search.MolSearchExample


new FileInputStream(Util.addPath("t.mrv")));


                   ^


MolSearchExample.java:79: cannot find symbol


symbol  : variable Util


location: class search.MolSearchExample


System.out.println(Util.dumpIntArray(hit));


                  ^


MolSearchExample.java:89: cannot find symbol


symbol  : variable Util


location: class search.MolSearchExample


System.out.println(Util.dumpInt2DArray(hitAll));


                  ^


3 errors



I am not sure what this Util library is referring to, but I have been unable to link to it. Am I perhaps missing a flag or something else on the CLASSPATH?

 



Thanks for the help!

User 6288f3e087

11-04-2011 13:40:36

Maybe I should add that also DuplicateSearch.java presents itself with similar issues, though this time it also cannot find the MoleculeImport module:




$ javac DuplicateSearch.java 


DuplicateSearch.java:41: cannot find symbol


symbol  : variable Util


location: class search.DuplicateSearch


   Util.standardInputFile());


   ^


DuplicateSearch.java:40: cannot find symbol


symbol  : variable MoleculeImport


location: class search.DuplicateSearch


   Molecule[] mols = MoleculeImport.moleculeArrayImport(


                     ^


Note: DuplicateSearch.java uses unchecked or unsafe operations.


Note: Recompile with -Xlint:unchecked for details.


2 errors




ChemAxon 42004978e8

13-04-2011 10:19:11

Hi,


 


The files in the example directory use other java files in the same directory, e.g. Util.java. In order to enable their usage the examples/java directory should be included.


In your case please include: ~/Chemaxon/JChem5.2/examples/java in the CLASSPATH as well.


Then you should be able to compile and the run the example file (java search.MolSearchExample
).


The same is true for the other example file.


Bye,


Robert



User 6288f3e087

14-04-2011 14:04:59

Robert:


Thank you for your reply. I successfully compiled Util.java. In order to make DuplicateSearch.java work, I also need the MoleculeImport class to work. So I try to compile this and get the following error:


$ javac MoleculeImport.java 

MoleculeImport.java:61: cannot find symbol

symbol  : variable Util

location: class search.MoleculeImport

   localPath ? Util.addPath(path) : path );

               ^

This is the CLASSPATH I'm using (please disregard the 5.2 of my previous e-mail):




$ echo $CLASSPATH

/usr/share/java/mysql.jar:/home/roberto/ChemAxon/JChem/lib/jchem.jar:/home/roberto/ChemAxon/JChem/marvin/sjars/util.jar:/home/roberto/ChemAxon/JChem/examples/java/search/Util.class:/home/roberto/Chemaxon/JChem/examples/java/search:/home/roberto/Chemaxon/JChem/examples/java

I'm trying to be overly careful by including both the Util.class and the directories on the classpath to no avail. Do you have any thoughts to what I may be missing?

Thanks,

Roberto


ChemAxon 42004978e8

16-04-2011 15:37:30

Hi Roberto,


Please paste the output of:



ls /home/roberto/Chemaxon/JChem/examples/java


then execute:


CLASSPATH=/home/roberto/ChemAxon/JChem/lib/jchem.jar:/home/roberto/ChemAxon/JChem/examples/java


and


javac /home/roberto/ChemAxon/JChem/examples/java/search/MolSearchExample.java


what are the outputs?


Bye,


Robert




 



User 6288f3e087

11-07-2011 20:42:18

Robert,


After postponing this problem for long enough, I finally got the example to compile, following your instructions (in the previous mesages:


$ javac -verbose ~/ChemAxon/JChem/examples/java/search/MolSearchExample.java


However, I cannot get this program to run:


$ java MolSearchExample
Exception in thread "main" java.lang.NoClassDefFoundError: MolSearchExample
Caused by: java.lang.ClassNotFoundException: MolSearchExample
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)


Any thoughts?


Thanks,


Roberto

ChemAxon 9c0afc9aaf

12-07-2011 04:06:01

CLASSPATH problem again: you should make sure the class file you created can be found via the CLASSPATH.


Most Java books give a good overview of the classpath and package hierarchy - this is an important concept to understand when starting to program in Java.