How to compile java snippet

User a0e3eb3dd1

25-09-2015 11:29:56

Hello!


I'm new in Java and need some advice what to do. I try compile Java snippet ShortestPath.java - https://www.chemaxon.com/forum/shortestpath-download201.java and receive following output.


$ javac -cp ~/ChemAxon/JChem/lib/jchem.jar ShortestPath.java 
ShortestPath.java:2: error: cannot find symbol
import chemaxon.struc.CGraph;
                     ^
  symbol:   class CGraph
  location: package chemaxon.struc
ShortestPath.java:73: error: cannot find symbol
    public void calculate( CGraph mg )
                           ^
  symbol:   class CGraph
  location: class ShortestPath
2 errors

Is CGraph located in another jar-file? Or is there another issue?


How to find the jar-file when you compile someone's snippets? I see imports in source code but I don't understand which jar file to link.


Pavel.

ChemAxon 2cd598e7ad

25-09-2015 15:05:05

Hi,


Some comments about your question are:
1) -cp is used to override the classpath. You may wanted to also include the current directory that you can do by appending it after the jchem.jar separated by a colon.


2) JChem API does not contain CGraph in it, it has been removed a very long time ago. Maybe you have a newer jchem.jar which simply does not contain the referenced classes anymore.


3) Can you tell us from what source did you receive this/these sources? As Chemaxon's source code is not open it can be quite a bit problematic.


As this forum exists to answer Chemaxon product related questions we can not provide Java support within it's bounds. Though we hope that you will be successful with Java and we wish you will.


Regards, Domi

User a0e3eb3dd1

25-09-2015 15:40:38

Hi, Domi!


Thank you.


This piece of code is from google. Just type "shortest path chemaxon", it will be the first link. I found some other links to java-files indexed by google as well. If this is a problem than keep these files away from the search engine.


Pavel.

ChemAxon 2cd598e7ad

28-09-2015 07:58:27

Hi,


Thanks for the information, we will look after google-indexed files if needed.


Best regards, Domi