Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to debug a Jar file

 
Mohtashim Shaikh
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohtashim Shaikh
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6320
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic