• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar

 
Anju sethi
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anju sethi
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting "unsupported version error"
 
Anju sethi
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
dream is for ever
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic