problem running Jar file

Hi

I am having the following problem :

I am jar-*** a directory from command line; the location of the newly created jar file is the same directory (I am using : - jar cfm File.jar Manifest.txt * - when positioned in dircetory X ) , directory X.

When I double click the jar file the application runs, but when I copy it elsewhere on the computer (for example desktop) and double click it there it won't work.

I would appreciate your help

Thanks,

Petru

[495 byte] By [PetruAniceta] at [2007-10-2 21:10:25]
# 1
Tell us how you know it doesn't work. Do you get an error message or what?
atmguya at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...
# 2

Well, this is what is really confusing - I am not getting any error message.

If I open the windows task manger - I am seeing a java process being created just for a short period (it ends very soon) - right after the double click on the jar file.

It works fine only in the directory where it has been created.

Also I have noticed that besides the jar file a "paths" file is created.

PetruAniceta at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...
# 3
Try running it from a command line: java -jar yourjar.jarThere may be an error message but you don't see it because double clicking invokes javaw so there is no console.
atmguya at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...
# 4

Thank you - you were of great help.

I ran it from the command line and the problem was it couldn't find some auxiliary jar files; this explains why in the directory were it was created - which contained the auxiliary jar files it did run (but nowhere else).

Now my next step was to place the jar files in the classpath.I am doing this by specifying it in the Manifest.txt file like this :

Main-Class: MyPackage.MainFrame

Class-Path: C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-api.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-impl.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-libs.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-xjc.jar C:/Sun/jwsdp-1.5/jwsdp-shared/lib/xsdlib.jar C:/Sun/jwsdp-1.5/jwsdp-shared/lib/relaxngDatatype.jar

The Class-Path attribute has its value (the 6 jar files) written in the same row.

The Manifest.txt file ends with a line-feed.

The generate MANIFEST.MF file looks good - it has both the Main-Class attribute and the Class-Path set correctly.

But another problem occurs - I am getting a NoClassDefFoundError for the MainFrame class... If I remove the classpath row from the Manifest.txt file the error does not occur any more but of course I am can't run the application because it doesn't find the classes it uses form the 6 jars.

Thank you for your help,

Petru

PetruAniceta at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...
# 5

Thank you - you were of great help.

I ran it from the command line and the problem was it couldn't find some auxiliary jar files; this explains why in the directory were it was created - which contained the auxiliary jar files it did run (but nowhere else).

Now my next step was to place the jar files in the classpath.I am doing this by specifying it in the Manifest.txt file like this :

Main-Class: MyPackage.MainFrame

Class-Path: C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-api.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-impl.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-libs.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-xjc.jar C:/Sun/jwsdp-1.5/jwsdp-shared/lib/xsdlib.jar C:/Sun/jwsdp-1.5/jwsdp-shared/lib/relaxngDatatype.jar

The Class-Path attribute has its value (the 6 jar files) written in the same row.

The Manifest.txt file ends with a line-feed.

The generate MANIFEST.MF file looks good - it has both the Main-Class attribute and the Class-Path set correctly.

But another problem occurs - I am getting a NoClassDefFoundError for the MainFrame class... If I remove the classpath row from the Manifest.txt file the error does not occur any more but of course I am can't run the application because it doesn't find the classes it uses form the 6 jars.

Thank you for your help,

Petru

PetruAniceta at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...
# 6

Thank you - you were of great help.

I ran it from the command line and the problem was it couldn't find some auxiliary jar files; this explains why in the directory were it was created - which contained the auxiliary jar files it did run (but nowhere else).

Now my next step was to place the jar files in the classpath.I am doing this by specifying it in the Manifest.txt file like this :

Main-Class: MyPackage.MainFrame

Class-Path: C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-api.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-impl.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-libs.jar C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-xjc.jar C:/Sun/jwsdp-1.5/jwsdp-shared/lib/xsdlib.jar C:/Sun/jwsdp-1.5/jwsdp-shared/lib/relaxngDatatype.jar

The Class-Path attribute has its value (the 6 jar files) written in the same row.

The Manifest.txt file ends with a line-feed.

The generate MANIFEST.MF file looks good - it has both the Main-Class attribute and the Class-Path set correctly.

But another problem occurs - I am getting a NoClassDefFoundError for the MainFrame class... If I remove the classpath row from the Manifest.txt file the error does not occur any more but of course I am can't run the application because it doesn't find the classes it uses form the 6 jars.

Thank you for your help,

Petru

PetruAniceta at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...
# 7

> Now my next step was to place the jar files in the

> classpath.I am doing this by specifying it in the

> Manifest.txt file like this :

>

> Main-Class: MyPackage.MainFrame

> Class-Path: C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-api.jar

> C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-impl.jar

> C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-libs.jar

> C:/Sun/jwsdp-1.5/jaxb/lib/jaxb-xjc.jar

> C:/Sun/jwsdp-1.5/jwsdp-shared/lib/xsdlib.jar

> C:/Sun/jwsdp-1.5/jwsdp-shared/lib/relaxngDatatype.jar

>

The Class-Path must contain relative paths (relative to the jar file). There's a bug report but it does not appear that Sun is going to do anything about it. In the description of the jar tool, it specifically states that Class-Path contains relative paths.

I don't know if this is the root cause of your problem, however. Except for the absolute paths, everything else looks OK to me.

atmguya at 2007-7-13 23:56:24 > top of Java-index,Desktop,Deploying...