Issue: When I try to run a java program on my personal machine I recieve the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: ecs100/UI
at BallDrop.<init>(BallDrop.java:37)
at BallDrop.main(BallDrop.java:63)
Caused by: java.lang.ClassNotFoundException: ecs100.UI
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Explanation: I am required to write a program using an external library 'ecs100'. It has been supplied as a .jar mime-type file.
I have the file test.java:
import ecs100.*;
class test{
public static void main(String args[]){
System.out.println('Test string');
UI.initialise(); //this is just how the library is supposed to be used
}
}
I have tried compiling with the command: javac -cp esc100.jar test.java
, which appears to load correctly.
Then when I attempt to run with the command java test
it gives the error I specified.
Details: I have been told that the library was written for oracle java 8. I have attempted to compile and run with oracle java 8 JDK, oracle java 9 JDK and openJDK 9 or 8.
I am running ubuntu 16.10. And I do not have any nVidia drivers installed (apparently that can cause problems).
I have tried running files compiled successfully from another computer. Even if they ran on that computer, no luck with mine.
The command java -version
outputs:
java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
The command javac -verison
outputs:
javac 1.8.0_121
Conclussion: I would greatly appreciate any feedback or suggestions.
I imagine I'm either doing something wrong with:
- The classpath in compilation
- The import statement
- A missing dependancy
- Wrong use of one of the commands
I am basically positive the problem is not one of the following:
- An issue with the way I am using the library