Need Help find java version of my app

Dear Friends How find the java version of my java application or source Suppose my application developed by using jdk1.1 Now i m using jdk1.3 and jdk1.4 In this case i want know the java version of my application
[248 byte] By [dfgfg] at [2007-9-30 20:51:38]
# 1

Versions are for applications. But in java there is major and minor versions for class files.

When JVM loads a class it gets it's major version. If this version is more than the JVM's max supported version then it wil not load the class.

JVM only loads the class if it's major version lies in the limit of the versions supported by the JVM.

The first four bytes of a class file are CAFEBABE, it is called magic number. Next four bytes are major and minor versions. Run the following code and see the output:

import java.io.InputStream;

public static void main(String argv[]) throws Exception{

InputStream stream = ClassLoader.getSystemResourceAsStream("java/lang/String.class");

byte[] bytes = new byte[4];

stream.read(bytes);

System.out.println("The first four bytes are:");

print(bytes);

stream.read(bytes);

System.out.println("\nNext four bytes are:");

print(bytes);

stream.close();

}

private static void print(byte[] bytes){

for(int i=0;i<bytes.length;i++){

System.out.print(getChar((bytes>>4) & 0xF));

System.out.print(getChar(bytes&0xF));

System.out.print(" ");

}

}

private static char getChar(int b){

if(b>15 || b<0){

return 'x';

}

if(b>=0 && b<=9){

return (char)('0'+b);

}

return (char)('A'+ (b-10));

}

The next four bytes are 00 00 00 30, so here 0030 is the major version. Now let your JVM supports upto 0020 then it will not load this class.

May this help.

Regards,

First_INTELLIGENT_Scientist at 2007-7-7 2:24:37 > top of Java-index,Administration Tools,Sun Connection...
# 2
Due to HTML conversion it has ommited loop index so change in the code as <code>bytes</code>
First_INTELLIGENT_Scientist at 2007-7-7 2:24:37 > top of Java-index,Administration Tools,Sun Connection...
# 3
System.getProperty("java.class.version");and System.getProperty("java.version"); http://java.sun.com/docs/books/tutorial/essential/system/properties.html
bjon045 at 2007-7-7 2:24:37 > top of Java-index,Administration Tools,Sun Connection...