• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.NoClassDefFoundError: –jar  RSS feed

 
Ali Alizadeh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi everybody

I want to compile and run a java GUI, I passed these steps:

1- javac *.java

2- jar –cfm GUI.jar manifesto *.class About_DL_POLY Acknowledge CERAMICS MINIDREI MINIOPLS WATER.300K TestInfo Licence Disclaimer

3- ./build

but I got this error:

bash: ./build: Permission denied

I tried to solve it, I use this command instead of it:

chmod 755 build

When I ran it I got this error :

..../execute$ java –jar
Exception in thread "main" java.lang.NoClassDefFoundError: –jar
Caused by: java.lang.ClassNotFoundException: –jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: –jar. Program will exit.
-------------------

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Did you specify the Main-Class in the manifest file?

And when you create your jar, what's with the "About_DL..." stuff. You just need "jar -cfm GUI.jar manifest *.class" assuming your class files are in current directory.

To run the jar the command is "java -jar GUI.jar".
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again.

Are you using the - operator before the cfm options? That looks like an – (=en‑dash) rather than a - to me.
 
Ali Alizadeh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dear Campbell and Tsang

In fact I'm newcomer in using of java,

Thank you for your reply

To Tsang, I forgot add GUI.jar

But I do not understand :

>>Did you specify the Main-Class in the manifest file?

And to Campbell:

I used a key that is next to the zero number in my keyboard or dash, What is wrong?
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ali Alizadeh wrote:I used a key that is next to the zero number in my keyboard or dash, What is wrong?

It really doesn't look like the same character. When I press the key to the right of the 0 key, I get this: -

But what you show above looks like this: –

Note the different lengths.

In fact, in this line from above, you use both characters:
2- jar –cfm GUI.jar manifesto *.class About_DL_POLY Acknowledge CERAMICS MINIDREI MINIOPLS WATER.300K TestInfo Licence Disclaimer

Do you see how there's a '-' and a '–' there? They should look the same.

It really seems like you're using the wrong character there, typing '–' when you need '-', and that's causing bad results for you.

 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ali,

There are two types of dash: en-dash ('–') and normal dash ('-'). You are supposed to use normal dash. The en-dash may cause because you are using a word processor while typing the command (and the word processor has auto-correct function enabled).

Regarding manifest file, if you want to make a jar as executable, then you need to create manifest file. The manifest file tells Java runtime where to find main class (entry point) for your application.

A typical manifest file is named as MANIFEST.MF, goes under Manifest dir, and contains main class' fully qualified class name.

Also, please share the output of below command:



I hope this helps.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many kinds of dash, but the key next to 0 on a British or US keyboard usually produces a hyphen, which is what you want. What you posted, as I said before, doesn't look like a hypnen, however.
 
Ali Alizadeh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dear All user

Thank you very much for your reply,

Yes, you were right, I changed the strange symbol into normal dash, and I could compile my package,
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!