This command did the trick:
java -classpath lib/OtpErlang.jar:. Game
I have missed the :. (which tells where my main class is, I suppose...)
Domanda
I have written a java program where I am using a .jar library (Jinterface). I compile it using:
javac -classpath lib/OtpErlang.jar Game.java Actions.java
where the lib dir is inside my project folder.
There is no error when compiling but I get a runtime error like this:
Exception in thread "main" java.lang.NoClassDefFoundError: com/ericsson/otp/erlang/OtpErlangObject
at Game.main(Game.java:7)
Caused by: java.lang.ClassNotFoundException: com.ericsson.otp.erlang.OtpErlangObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more
And I think that it has to do with the classpath, what is wrong?
Here is the Game class:
import java.io.IOException;
public class Game {
public static void main(String[] args) throws IOException {
Actions server = new Actions();
server.moveRight();
}
}
Soluzione 2
This command did the trick:
java -classpath lib/OtpErlang.jar:. Game
I have missed the :. (which tells where my main class is, I suppose...)
Altri suggerimenti
Try running it like this, from the root of all your java packages:
java -classpath lib/OtpErlang.jar Game
Try like this.I hope this will help.....
javac -cp . lib/OtpErlang.jar Game.java Actions.java