简体   繁体   English

如果我使用Java 1.4版本编译代码,则Java 1.7 JVM能够运行.class文件

[英]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). 我正在开发基于1.4和Java 1.4轴构建的现有Web服务代码,现在我们正在使用Java 1.7升级所有服务器,我们正面临将1.4升级到1.7的问题(因为org.apache.enum depricatedin Java 1.5及更高版本)。

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). 因此,我们计划使用Java 1.4编译代码并生成war文件,并将该war文件部署在apache tomcat(版本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. 我觉得一旦编译器生成了字节码,它将不再依赖Java版本来运行.class文件。

please suggest me if I am mistaken anything. 如果我有误,请提出建议。

Yes. 是。 JVM(Java Virtual Machin) would run your class file without any problem. JVM(Java Virtual Machin)可以毫无问题地运行您的类文件。

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. 但是,如果尝试在1.7 SDK中编译Java代码(.java),则可能会导致上述专家的评论中提到的问题。

Java is a platform independent language. Java是与平台无关的语言。

Once you write a java program (.java), java compiler converts it into byte codes (.class) or you can say machine code of the processor. 编写Java程序(.java)后,Java编译器会将其转换为字节码(.class),或者可以说处理器的机器代码。

Now you can run (in correct term "interpret") this byte code on any machine with JVM. 现在,您可以在任何具有JVM的机器上运行(正确的术语“解释”)此字节代码。 JVM varies from platform to platform (platform dependent).You can consider JVM as processor purely implemented with software. JVM因平台而异(取决于平台)。您可以将JVM视为纯粹由软件实现的处理器。

That's the beauty of java "write once, run anywhere". 这就是Java“编写一次,随处运行”的美。 All you need is correct JVM for your machine. 您所需要的就是为您的计算机提供正确的JVM。

For further reading... 进一步阅读...

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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