• 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 in thread "main" java.lang.NoClassDefFoundError: –jar

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
-------------------

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
reply
    Bookmark Topic Watch Topic
  • New Topic