The Artima Developer Community
Sponsored Link

Java Answers Forum
I am having a hard time running a jar file.

3 replies on 1 page. Most recent reply: Jul 28, 2003 9:43 AM by Greg Lehane

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Clay Dagler

Posts: 21
Nickname: cdagler
Registered: Jul, 2003

I am having a hard time running a jar file. Posted: Jul 27, 2003 9:29 PM
Reply to this message Reply
Advertisement
I am having a hard time running a jar file.

I have all of my *.java files in the same dir. My manifest file ett.mf (which is in the same dir) contains:

Main-Class: Application1

And the main class is in Application1.java This is what I get when I run these commands:

C:\Java\ett>javac *.java

C:\\Java\ett>jar cfm ett.jar ett.mf *.class

C:\\Java\ett>java - jar ett.jar
Exception in thread "main"
java.lang.NoClassDefFoundError: Application1 (wrong n
ame: ett/Application1)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass
(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown
Source)
at java.net.URLClassLoader.access$100(Unknown
Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.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)

Please help me fix java.lang.NoClassDefFoundError

Thanks,
Clay


Greg Lehane

Posts: 33
Nickname: glehane
Registered: Jun, 2003

Re: I am having a hard time running a jar file. Posted: Jul 27, 2003 9:54 PM
Reply to this message Reply
Is your main class in a package? If so, you have to declare its full name in the manifest.

e.g. Main-Class: ett.Application1

Hope this helps,

=- Greg

Clay Dagler

Posts: 21
Nickname: cdagler
Registered: Jul, 2003

Re: I am having a hard time running a jar file. Posted: Jul 28, 2003 6:21 AM
Reply to this message Reply
Yes I am using a packege and I changed my manifest file to

Main-Class: ett.Application1

and now this is what I got:

C:\Java\ett>javac *.java

C:\Java\ett>jar -cfm ett.jar ett.mf *.class

C:\Java\ett>java -jar ett.jar
Exception in thread "main"
java.lang.NoClassDefFoundError: ett/Application1

Thanks,
Clay

Greg Lehane

Posts: 33
Nickname: glehane
Registered: Jun, 2003

Re: I am having a hard time running a jar file. Posted: Jul 28, 2003 9:43 AM
Reply to this message Reply
Your Application1 file should also be in a sub-directory called "ett" within your jar file.

Try moving to the parent directory (cd ..) before running the "jar" tool. Something like -

C:\Java>jar -cfm ett.jar ett.mf ett\*.class

You can open the jar file with winzip to see if the directory structure has been maintained.

=- Greg

Flat View: This topic has 3 replies on 1 page
Topic: java install help Previous Topic   Next Topic Topic: -==ALL BEST Software And Cracks For YOU!!!==-(CAM, CAD, ext.)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use