Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Thrown when i try to run a jar file

 
Georg S. Nieuwoudt
Greenhorn
Posts: 1
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am currently having a problem with running a jar.
This is the exception is gives:

Exception in thread "main" java.lang.NoClassDefFoundError: C:\OptCon/jar
Caused by: java.lang.ClassNotFoundException: C:\OptCon.jar
at java.net.urlClassLoader$1.run(Unknown Source)
at java.seurity.AccessController.doPrivileged(Native Method)
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: C:\OptCon.jar. Program will exit.

Now i checked in my jar file, all the class files are there and the manifest file is created right.

What am i missing here?

Thanks in advance...
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Georg . How do you ran it (i.e: complete command)? And what are the contents of the jar file?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you're trying to execute a jar file, rather than a class within it. You say you did everything right, but provide no information for us to actually *check*, so we can't help.

TellTheDetails.

And welcome to JavaRanch!
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something tells me you tried "java C:\OptCon.jar". This will treat "C:\OptCon.jar" as a class name, not a JAR file. Try "java -h" and see what options you have. Hint: what you need is mentioned all the way at the top. Don't forget to add a Main-Class in your JAR file's manifest file (if you've created it yourself).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic