32位/64位系统,jdk32位,64位,32/64位jdk编译出来的class和eclipse 32位和64位

首先关于32位/64位系统,jdk32位,64位,32/64位jdk编译出来的class和eclipse 32位和64位的一些对应关系做些说明。

1.32位操作系统不可以装64位jdk,64位操作系统一般都可以安装32位jdk,64位jdk是完美发挥性能的。

2.64位eclipse只能在64位jdk上运行,运行时如不指定(在eclipse.ini中或启动参数中)vm是会默认去取JAVA_HOME的,如未配置,则根据path中制定去寻找jre路径,这个下面详述。32位eclipse也只能在32位jdk上运行,一句话:eclipse和jdk的位数应该是对应的,否则报错类似下面这种:

    Failed to load the JNI shared library "E:\Java\bin\..\jre\bin\client\jvm.dll".

 3.class文件无论是32位还是64位jdk编译出来的,都可以通用,也不分是window的jdk还是linux的jdk。

注意如果想安装多个jdk又不想改动javahome的话,可以在eclipse.ini  修改,为eclipse设jdk,这样启动不同的eclipse时就不会有问题了。解决方法简述:

 eclipse在启动时会去读取eclipse.ini配置文件。加上红字部分即可(根据自己的实际路径),注意加的位置。

-startup
plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.400.v20160518-1444
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
E:\Program Files\Java\jdk1.8.0_92\jre\bin\server\jvm.dll       --这里其实也可配javaw.exe   .但是启动时会有一个eclipse.exe 和一个javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m

关于path中配置了多个jdk,加载顺序是先入为主。就是第一个出现的就是用到的,而后面的会被忽略,而不是覆盖。所以一般比较好的情况,是在path中把你自己添加的jdk的bin文件的路径放到最前边,如果还是不太懂,请看这一文章:http://ihyperwin.iteye.com/blog/1513754

还有在windows系统中最好设置个JAVA_HOME变量,在path中如下配置%JAVA_HOME%\bin,好处就是假设你把java安装目录修改了,修改JAVA_HOME的值即可,其他的不用跟着修改了,类似Linux的符号链接,你懂的。

Before answering this specific question , let us understand what we mean when we use the term "32-bit" and "64-bit"

The difference in 32-bit and 64-bit can occur at 3 different layers

  1. Processor : A 32 bit processor is one which handles instruction set using 32 bit addressing and hence can  point to physical memory upto 4GB. A 64 bit processor uses 64-bit addressing and can point physical memory > 4GB. Hence in order to *effectively* use RAM more than 4GB , you should have processors of 64-bit.
  2. OS : An OS can be 32-bit or 64-bit which effectively means the virtual memory they support. A 64-bit operating systems which has ability to create virtual memory larger than 4 GB. Theoretically , they can run on top of 32 bit processors as well but they will not be much useful. In fact, when Linux became the first OS to fully support x86_64 in 2001, it was developed on simulators on 32-bit processors. 
  3. Native Application : These are applications which are compiled to 64-bit addressing system to fully utilize 64 bit OS. A 64 bit JRE is a native application compiled using 64-bit compilers for that specific OS/processor combination ( aka platform).

A java application is not a native application. It is a java byte code which runs in JRE. Java byte code generated by java compiler does not change between 32-bit and 64-bit.
Hence, you can safely use a java application compiled using 64 bit JDK on 32 bit JRE.

猜你喜欢

转载自blog.csdn.net/hejisan/article/details/82778336
今日推荐