• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception Thrown when i try to run a jar file

 
Greenhorn
Posts: 1
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic