.jar file cant find main class
ok, i made a game which consisted of two java files:
- BettingGame.java
- BettingGame_MainClass.java.
I compiled them and got:
- BettingGame.class
- BettingGame$Listener.class
- BettingGame_MainClass.class
I threw in a manifest file stating the following
Code:
Main-Class: BettingGame_MainClass\n
\n
and created the .jar file in terminal with the following command:
Code:
jar cfm BettingGame.jar manifest.txt BettingGame_MainClass.class BettingGame.class BettingGame$Listener.class
and i succesfully got a .jar file.
When I tried to run the .jar file using:
Code:
[java -jar BettingGame.jar
I get the following errors
Exception in thread "main" java.lang.NoClassDefFoundError: BettingGame$Listener
at BettingGame.<init>(BettingGame.java:60)
at BettingGame_MainClass.main(BettingGame_MainClass.j ava:6)
Caused by: java.lang.ClassNotFoundException: BettingGame$Listener
at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
Where did i go wrong?
I followed the steps from this video: YouTube - How to create Java executables/jar file