• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting "unsupported version error"
 
Anju sethi
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
it's a teeny, tiny, wafer thin ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic