aspose file tools*
The moose likes Beginning Java and the fly likes How to debug a Jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to debug a Jar file" Watch "How to debug a Jar file" New topic
Author

How to debug a Jar file

Mohtashim Shaikh
Ranch Hand

Joined: Jul 18, 2010
Posts: 43
I have a jar file with Java Swings implemented.

Main class has been specified.

When I execute it on my machine and click on the button I get the desired result.

When I send this jar to my friends machine and asked him to click on the button it somehow did not work.

How can I debug on his machine where and why did they jar not function properly ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14274
    
  21

Mohtashim Shaikh wrote:... it somehow did not work.

How exactly did it not work?

Instead of double-clicking the JAR file, run it from a command prompt window with a command like this: java -jar TheJarFile.jar

If any error messages are shown, then copy & paste them here.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Mohtashim Shaikh
Ranch Hand

Joined: Jul 18, 2010
Posts: 43
With your help I am now able to see the error on the remote machine, however I have no clue how to resolve the error.



Error:



MENIFEST.MF

****************

Manifest-Version: 1.0
Class-Path: lib/jai-core-1.1.3-alpha.jar lib/jai_codec-1.1.3-alpha.jar
lib/jai_imageio-1.1-alpha.jar
Created-By: 1.5.0_11 (Sun Microsystems Inc.)
Main-Class: other.Uploader

******************

I am building the Manifest file using the below command.



Manifest.txt

**************
Main-Class: other.Uploader
Class-Path: lib/jai-core-1.1.3-alpha.jar lib/jai_codec-1.1.3-alpha.jar lib/jai_imageio-1.1-alpha.jar


**************

Please help me overcome the issue and help me set the correct classpath for the jars according to my application directory structure.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Does your friend have access to:

lib/jai-core-1.1.3-alpha.jar
lib/jai_codec-1.1.3-alpha.jar
lib/jai_imageio-1.1-alpha.jar
Mohtashim Shaikh
Ranch Hand

Joined: Jul 18, 2010
Posts: 43
Stephan van Hulst wrote:Does your friend have access to:

lib/jai-core-1.1.3-alpha.jar
lib/jai_codec-1.1.3-alpha.jar
lib/jai_imageio-1.1-alpha.jar


No, but I have put these jar files inside my application jars's lib folder so that the end users dont have to explicitly set it in the classpath but use it from inside the jar executable.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14274
    
  21

Mohtashim Shaikh wrote:No, but I have put these jar files inside my application jars's lib folder

That's not going to work. Java is not going to look inside the lib folder inside your JAR to find those libraries - Java unfortunately does not support nested JARs.

Mohtashim Shaikh wrote:so that the end users dont have to explicitly set it in the classpath but use it from inside the jar executable.

They don't need to explicitly set the classpath. In fact, Java does not look at the CLASSPATH environment variable at all when running an executable JAR file. The only thing that's necessary is to have the lib folder with the libraries in the same directory as your JAR file.
Mohtashim Shaikh
Ranch Hand

Joined: Jul 18, 2010
Posts: 43
Jesper de Jong wrote:
Mohtashim Shaikh wrote:No, but I have put these jar files inside my application jars's lib folder

That's not going to work. Java is not going to look inside the lib folder inside your JAR to find those libraries - Java unfortunately does not support nested JARs.

Mohtashim Shaikh wrote:so that the end users dont have to explicitly set it in the classpath but use it from inside the jar executable.

They don't need to explicitly set the classpath. In fact, Java does not look at the CLASSPATH environment variable at all when running an executable JAR file. The only thing that's necessary is to have the lib folder with the libraries in the same directory as your JAR file.


If so, then what is the use and point of the below feature by Java ?

http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
Note the line: "The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file...". As Jesper said, it points to jar files outside of the main jar file, not to jar files that are part of it.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to debug a Jar file