File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar" Watch "jar" New topic
Author

jar

Anju sethi
Ranch Hand

Joined: Dec 26, 2005
Posts: 91
Hi,

I have downloaded a jar from net. I have no idea about which version was used to compile the java classes and resulting into jar file.

Now, I am trying to execute this executable jar file using java -jar utility. It is not running by java 1.3 which is set by me in path.

Now i want to try executing the same file using 1.4.
I want to know:

1. Is there any option in java.exe for specifying the path of 1.4 as we have -sourcepath in javac?
2. How to find which version was used to compile java classes in jar file?

I hope I am clear.
Please help.

Thanks,
Anju Sethi



thanks,<br />Anju Sethi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
You could explicitly use the path to java/javaw if you want to make sure you're using a particular one, e.g. "C:\j2sdk1.4\bin\java.exe ...". I'm not sure if that works unless your JAVA_HOME environment variable is set to point to the 1.4 installation as well, though.

I don't think you can find out which JDK was used to compile the code. The best you can do is probably to look at the class file version of a class in that jar; that will tell you for which JDK it was compiled (which can be different from the JDK version used to compile it, due to the -target switch).


Ping & DNS - my free Android networking tools app
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Originally posted by Anju sethi:
Now, I am trying to execute this executable jar file using java -jar utility. It is not running by java 1.3 which is set by me in path.


Why not? What is the error message you get?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Anju sethi
Ranch Hand

Joined: Dec 26, 2005
Posts: 91
I am getting "unsupported version error"
Anju sethi
Ranch Hand

Joined: Dec 26, 2005
Posts: 91
It is working with JDK 1.4 only if i change my JAVA_HOME to JDK 1.4 from JDK 1.3.
But my project requires me to use JDK 1.3 and jar file need JDK 1.4

I do not want to change java_home again and again. Is there any other way by which i can execute my jar by JDK 1.4 without changing Java_home.

Please help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
You don't mention what kind of jar file this is that you downloaded, but is there a chance you can get the source code for it and recompile it using JDK 1.3 (which might involve some porting effort, of course) ?
Anju sethi
Ranch Hand

Joined: Dec 26, 2005
Posts: 91
Thanks.
dream is for ever
Greenhorn

Joined: May 06, 2005
Posts: 2
The simplest way is to create a batch file and run your jar file using that


e.g. Following might be the content of Batch file.

--------------------
SET JAVA_HOME="<JDK1.4 HOME>"

%JAVAHOME%/bin/java -jar <jarfile>

-----------------

Cheers
 
 
subject: jar
 
Similar Threads
ANT classpath
Unsuccessfull build due to wrong version 49.0
cannot access stub
JAXP 1.0
how to run a jar file from the cmd prompt using a specific jre version