0

I am having a problem with use of this open source development kit - https://github.com/cdk/cdk

Here is the java code for BasicProgram:

import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.Atom;

public class BasicProgram {
   public static void main(String args[]) throws Exception {
       IAtom atom = new Atom("C");
       System.out.println(atom);
    }
}

When I go to compile the class file is generated without errors, but doesn't seem to find the references in the jar file:

E:\Cheminformatics>javac -cp cdk-2.0.jar BasicProgram.java

E:\Cheminformatics>java -cp . BasicProgram
Exception in thread "main" java.lang.NoClassDefFoundError: org/openscience/cdk/Atom
        at BasicProgram.main(BasicProgram.java:6)
Caused by: java.lang.ClassNotFoundException: org.openscience.cdk.Atom
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Alex G
  • 807
  • 6
  • 13
  • 1
    It is because the cdk jar is not on the classpath when you run it. Try something like this: java -cp ".;cdk-2.0.jar" BasicProgram – Balázs Nemes Jun 15 '17 at 19:04
  • Doesn't seem to be the issue- I then get "Error: Could not find or load main class .;cdk-2.0.jar" – Alex G Jun 16 '17 at 00:42
  • :) The isse is what I wrote. I forgot to format my answer. This is how the command looks like: `java -cp ".;cdk-2.0.jar" BasicProgram` – Balázs Nemes Jun 16 '17 at 07:23

0 Answers0