This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes determining which version of java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "determining which version of java" Watch "determining which version of java" New topic
Author

determining which version of java

Sunny Gibbony
Ranch Hand

Joined: May 14, 2008
Posts: 39
I am looking at some java classes but i'm not sure which version of java it was written in. I don't know if its java se 1.4 or 1.5 etc...

Is there a definate way to find out which version of java the code is written in?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Not really. But you can find out which version of the class file format was used - that's generally a clue which Java version they were intended for. The bytes #6 and #7 of the class file provide this hint: http://en.wikipedia.org/wiki/Class_(file_format)


Ping & DNS - updated with new look and Ping home screen widget
Prasad Tamirisa
Ranch Hand

Joined: Mar 26, 2007
Posts: 130
Here you go to find the java version.
1) Open command prompt.
2) type in .


Regards,
Durga Prasad
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

Prasad, that tells you which version of Java is the default used on your system, but it does not tell you if a Java source file was written for Java 1.4, Java 5 etc. or with which version of Java a class file was compiled.


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

Joined: Mar 26, 2007
Posts: 130
that tells you which version of Java is the default used on your system
Agreed. Apologies for my mistake.

Anyway, I have an another way to do it. Type in the following command in the command prompt.


This will give a BIGGGGGGGGGGGGGG list of bla bla bla bla. Take the major and minor versions from the output.
This is not all .... You may need to do some more work to search in sun release notes for the corresponding major and minor versions.
[ May 17, 2008: Message edited by: Prasad Tamirisa ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36578
    
  16
Yes, you are right. I never knew that. I am getting major version 50 and minor version 0 and I know 50 is Java6 (1.6.0). Unfortunately I don't know where to find a list of all version numbers. I think they started about 45.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Unfortunately I don't know where to find a list of all version numbers. I think they started about 45.

The link I posted above has such a list.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36578
    
  16
Thank you, Ulf. The list is incomplete, but there is a 2nd link to where you can find the rmissing bits.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: determining which version of java
 
Similar Threads
Mac-specific applet-Javascript communication problem
After studying for weeks I just failed the practice exam. What should I study?
in which language java is written
JAVA 1.5
will struts 1.1 supports java 6?