I'm relatively new to Java and I was trying to make one my programs more accessible to my non-computer savvy friends with java web start. I took my .class file and archived it with the command:

jar -cf TabbedLatinHelp.jar TabbedLatingHelp.class

I then created a .jnlp file and uploaded the .jar file and the .jnlp file to a web server.
When I download and run the .jnlp file I get the following exception:

java.lang.ClassNotFoundException: TabbedLatinHelp 
        at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
	at com.sun.javaws.Launcher.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Here's a link to the site with all my files: http://nocookies92.webs.com/
If anyone could help me figure out what I did wrong, I'd greatly appreciate it. Thanks in advance.

Recommended Answers

All 14 Replies

Check your spellings. The posted jar command shows a g in the class name?
Java is case sensitive.

Yes, that's just a type-o on my part, I double checked the spelling and caps when I actually entered the command.

Why not copy and paste rather than typing in the wrong data?

Did you check ALL your spellings? How many places are the class names spelled out?

I didn't copy and paste because I archived it a day a ago. I guess I can go back and re-do the archiving again and check my spelling again.

I'm having trouble running my .jar file too, even from the command line. every time I try to run it gives me the windows "error" sound. Any suggestions?

Can you copy and paste here the contents of the command prompt screen when you try to run the jar? There could be info in the error message.
To copy the command prompt screen:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.

Here's my command prompt screen:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\person>cd my documents

C:\Documents and Settings\person\My Documents>TabbedLatinHelp.jar

C:\Documents and Settings\person\My Documents>

There's no error message, it just makes the "error" sound. My .class file runs perfectly fine when I run it from the command line by the way, so that's not the problem.

What you have pasted doesn't show any command. The commandline associated with the .jar file executes and reads the .jar file trying to find a manifest file with a Main-Class: entry. Does your jar file have a manifest with a Main-Class entry?

What do you think that entering the name of a jar file on a command line should do?
If you build the jar file, did you configure it so it could be executed?

I just re-made the jar file with a manifest, here's my command prompt's contents:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\person>cd my documents

C:\Documents and Settings\person\My Documents>jar cvfm TabbedLatinHelp.jar manif
est.txt TabbedLatinHelp.class
added manifest
adding: TabbedLatinHelp.class(in = 3432) (out= 1806)(deflated 47%)

I get the same "error" sound when trying to run it, through both double clicking it and command line execution. The website I read told me that entering the name of the jar file on the command line was how to test the jar file. The Main-Class in the manifest is TabbedLatinHelp.
How do I configure a jar file to be executed, I thought it was executable automatically?

What is in the manifest file you've added to your jar file? Show by copy and pasting the contents. Your post of: 'Main-Class in the manifest is TabbedLatinHelp" doesn't show the contents of the file.

How do I configure a jar file to be executed, I thought it was executable automatically?

You add a correctly configured manifest to the jar file.

Execute the jar file using the java command as follows:

java -jar TabbedLatinHelp.jar

Copy and paste contents of screen here.

The problem with the default execution that you are trying to do is that it uses the javaw.exe command which does NOT show error messages on a command prompt window.

Look at this command prompt screen. It appears that you have a spelling error(see earlier post about being sure to check spelling):

D:\JavaDevelopment\Testing\JNLP\Original>java -cp TabbedLatinHelp.jar TabbedLatinHelp
Exception in thread "main" java.lang.NoClassDefFoundError: TabbedLatinHelp
Caused by: java.lang.ClassNotFoundException: TabbedLatinHelp
        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)
Could not find the main class: TabbedLatinHelp.  Program will exit.

D:\JavaDevelopment\Testing\JNLP\Original>java -cp TabbedLatinHelp.jar TabbedlatinHelp
Exception in thread "main" java.lang.NoClassDefFoundError: TabbedlatinHelp (wrong name: TabbedLatinHelp)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        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$000(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)
Could not find the main class: TabbedlatinHelp.  Program will exit.

D:\JavaDevelopment\Testing\JNLP\Original>

java.lang.NoClassDefFoundError: TabbedlatinHelp (wrong name: TabbedLatinHelp)
The class filename has a lowercase letter in it, where the class name is upper.

Isn't that spelling an error on your part? Anyway, here's the error code:

C:\Documents and Settings\person\My Documents>java -jar TabbedLatinHelp.jar
Exception in thread "main" java.lang.NoClassDefFoundError: TabbedLatinHelp
Caused by: java.lang.ClassNotFoundException: TabbedLatinHelp
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)
Could not find the main class: TabbedLatinHelp . Program will exit.

and I attatched the manifest file, so you can take a look. Thanks for all of your help.

Isn't that spelling an error on your part?

No. It was the spelling of the class name in the jar file I downloaded from http://nocookies92.webs.com/

Download it and look inside and see.

Here's what I extracted from that jar file:


C:\Temp\testing>dir
Volume in drive C has no label.
Volume Serial Number is B408-DB22

Directory of C:\Temp\testing

07/30/2010 08:06 PM <DIR> .
07/30/2010 08:06 PM <DIR> ..
07/30/2010 08:06 PM <DIR> META-INF
07/19/2010 08:21 PM 3,395 TabbedlatinHelp.class
1 File(s) 3,395 bytes
3 Dir(s) 4,523,008,000 bytes free

C:\Temp\testing>

That seems to have been the problem all along. I uploaded the new .jar file and it works now. Shame all of that was just for a type-o. Thanks for all of your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.