aspose file tools*
The moose likes Beginning Java and the fly likes Exception Thrown when i try to run a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception Thrown when i try to run a jar file" Watch "Exception Thrown when i try to run a jar file" New topic
Author

Exception Thrown when i try to run a jar file

Georg S. Nieuwoudt
Greenhorn

Joined: Feb 20, 2009
Posts: 1

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

Joined: Mar 24, 2008
Posts: 3855

Welcome to JavaRanch Georg . How do you ran it (i.e: complete command)? And what are the contents of the jar file?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Oct 27, 2005
Posts: 19762
    
  20

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Exception Thrown when i try to run a jar file