简体   繁体   中英

If I compiled the code using java 1.4 version would the java 1.7 JVM able to run the .class files

I am working on existing webservice code which was built on axis 1.4 and java 1.4,now we are upgrading all servers with java version 1.7, We are facing problem with upgrading 1.4 to 1.7(as org.apache.enum depricatedin java 1.5 and above version).

so we are planning to compile the code with java 1.4 and generate war file, deploy that war file in apache tomcat(version 6).

does it impact my webservice?? I feel once the byte code is generated by the compiler it wont depend on java version to run .class file.

please suggest me if I am mistaken anything.

Yes. JVM(Java Virtual Machin) would run your class file without any problem.

However if you will try to compile your java code (.java) in 1.7 SDK, it may cause problem as mentioned in comments by experts, above.

Java is a platform independent language.

Once you write a java program (.java), java compiler converts it into byte codes (.class) or you can say machine code of the processor.

Now you can run (in correct term "interpret") this byte code on any machine with JVM. JVM varies from platform to platform (platform dependent).You can consider JVM as processor purely implemented with software.

That's the beauty of java "write once, run anywhere". All you need is correct JVM for your machine.

For further reading...

https://en.wikipedia.org/wiki/Java_virtual_machine

http://docs.oracle.com/cd/E19455-01/806-3461/6jck06gqd/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM