简体   繁体   English

将JDK从32位升级到64位

[英]upgrade JDK from 32 bit to 64 bits

I have a program using JDK 1.7 running on Windows Server 2008 (32 bits). 我有一个使用Windows Server 2008(32位)上运行的JDK 1.7的程序。 If I want to re-deploy the program to the latest Windows Server (64 bits), do I need to rewrite the program or just minor change is ok? 如果我想将该程序重新部署到最新的Windows Server(64位),是否需要重写该程序,或者可以稍作更改吗?

Thanks a lot! 非常感谢!

Short answer 简短答案

No , you should not need to change your code. ,你不应该需要改变你的代码。 You don't even need to recompile it. 您甚至不需要重新编译它。 Just run your JAR/class and it should work fine. 只需运行您的JAR /类,它就可以正常工作。

You didn't provide much details of your application, so I ask you to read the long answer for more info, since there are considerations which might help you in the future. 您没有提供太多有关应用程序的详细信息,所以我请您阅读详细的答案以获取更多信息,因为将来有一些注意事项可能会对您有所帮助。

Long answer 长答案

The Java Compiler generates bytecodes which are later interpreted by the JVM. Java编译器生成字节码 ,然后由JVM解释。 The JVM translate the bytecode into native commands. JVM将字节码转换为本地命令。 The JVM will do the "hard work" while you can focus on one single program. JVM将进行“艰苦的工作”,而您可以专注于一个程序。 The Java platform is platform independent, therefore you should not need to change your code if you are going from 32 bits to 64 bits Windows. Java平台是独立于平台的,因此,如果您要从32位Windows变为64位Windows,则无需更改代码。

As always, there are some exceptions , which go beyond the 32/64 bits case. 与往常一样,有一些例外 ,超出了32/64位的情况。 I will list some for example: 我将列举一些例子:

  • Breaking lines in Linux and Windows while working with persistence (MS files usually have carriage return) 在进行持久性处理时,Linux和Windows中的换行符(MS文件通常带有回车符)
  • Using JNI to consume native libraries (This might impact 32/64 bit programs) 使用JNI消耗本机库(这可能会影响32/64位程序)
  • Fonts used on different operational systems 在不同操作系统上使用的字体
  • Maybe some Java bug, but very improbable 也许是一些Java错误,但是非常不可能

As a general practice, if you are going to cross platform your application, try to find the "boundaries" of your program. 通常,如果要跨平台应用程序,请尝试查找程序的“边界”。 When do you have go "outside" your application to seek specific OS resources? 您什么时候可以“外出”您的应用程序来寻找特定的OS资源?

Even if your program runs in an application server, such as JBoss, you should not need to change your code. 即使您的程序在JBoss之类的应用程序服务器中运行,您也无需更改代码。

I think your program will work fine without any changes, just keep in mind that exceptions may apply. 我认为您的程序无需进行任何更改即可正常运行,请牢记可能会应用例外情况。

I don't think you need to change anything. 我认为您无需更改任何内容。 Do you use any native code through jni? 您是否通过jni使用任何本机代码?

First, are you using JDK or JRE on the 32 bit Windows? 首先,您是在32位Windows上使用JDK还是JRE? You just need JRE to run your application. 您只需要JRE即可运行您的应用程序。

Second, on Windows 8, you can still install 32 bit JRE so your application should run. 其次,在Windows 8上,您仍然可以安装32位JRE,以便您的应用程序可以运行。

Third, if you installed 64 bit JRE, your application should still run. 第三,如果安装了64位JRE,则应用程序仍应运行。 There might be more bugs in 64 bit JRE. 64位JRE中可能会有更多错误。 If you encounter a lot of bugs, just use 32 bit JRE instead. 如果遇到很多错误,请改用32位JRE。

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

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