1. 程式人生 > >64位系統下同時使用64位和32位的eclipse

64位系統下同時使用64位和32位的eclipse

64位系統下同時使用64位和32位的eclipse

eclipse.ini 檔案使用說明

The -vm option and its value (the path) must be on separate lines.

The value must be the full absolute or relative path to the Java executable, not just to the Java home directory.

The -vm option must occur before the -vmargs option, since everything after -vmargs is passed directly to the JVM.

For the 32-bit Eclipse executable (eclipse.exe on Windows) a 32-bit JVM must be used and 
for the 64-bit Eclipse executable a 64-bit JVM must be used. 
32-bit Eclipse will not work with a 64-bit JVM.

複製程式碼

要所有的軟體,硬體,全是64位的,你的應用才算成功的執行在64位上了。比如:

使用64位的CPU,現在(2006年以後生產)的CPU都是64位。
安裝64位的作業系統,比如64位的windows 7
安裝64位的JDK,比如jdk-6u25-windows-x64.exe
安裝64位的eclipse,比如eclipse-jee-helios-SR2-win32-x86_64.zip

複製程式碼

 

http://blog.csdn.net/jacarri/article/details/9785683

32位JDK安裝目錄是D:\Java\32\jdk1.6.0_13

64位JDK安裝目錄是D:\Java\jdk1.7.0_06

 

JAVA_HOME配置的是JAVA_HOME=D:\Java\32\jdk1.6.0_13

 

然後啟動64位的eclipse果斷的報錯了,報錯資訊:

[Failed to load the JNI shared library "D:\Java\32\jdk1.6.0_13\bin\..\jre\bin\client\jvm.dll".],

想到環境變數配置的是32位的JDK,果斷的確認是eclipse使用了預設的配置,要解決這個問題就要在64位eclipse.ini中指定jvm的位置.

配置方法如下:

  在eclipse.ini檔案中找到openFile,在下面新增如下兩行:

-vm  
D:/Java/jdk1.7.0_06/bin/javaw.exe  

注意上面兩行不能寫在同一行上喲.

 

   為了保證以後將環境變數的jdk切換到64位後,32位的eclipse報錯,所以順便32位的eclipse的配置檔案也做了類似的配置

  如果改配置後出現這個錯誤[Java was started but returned exit code=13]  ,可能是你給64位的eclipse指定了32位的jvm.

 

上我64位eclipse使用的配置檔案

複製程式碼

-startup  
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar  
--launcher.library  
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502  
-product  
org.eclipse.epp.package.java.product  
--launcher.defaultAction  
openFile  
--launcher.XXMaxPermSize  
256M  
-showsplash  
org.eclipse.platform  
--launcher.XXMaxPermSize  
256m  
--launcher.defaultAction  
openFile  
-vm  
D:/Java/jdk1.7.0_06/bin/javaw.exe  
-vmargs  
-Dosgi.requiredJavaVersion=1.5  
-Xms40m  
-Xmx384m  
-XX:PermSize=256M   
-XX:MaxPermSize=256M  
-verbose:gc  
-XX:+PrintGCDetails  
-XX:+PrintGCDateStamps  
-Xloggc:D:/application/eclipse-android/gc.log  

複製程式碼

上32位eclipse使用的配置檔案

複製程式碼

-startup  
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar  
--launcher.library  
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502  
-product  
org.eclipse.epp.package.jee.product  
--launcher.defaultAction  
openFile  
--launcher.XXMaxPermSize  
256M  
-showsplash  
org.eclipse.platform  
--launcher.XXMaxPermSize  
256m  
-vm  
D:/Java/32/jdk1.6.0_13/bin/javaw.exe  
--launcher.defaultAction  
openFile  
-vmargs  
-Dosgi.requiredJavaVersion=1.5  
-Xms40m  
-Xmx512m  

複製程式碼

  

http://blog.csdn.net/wangxianshou/article/details/7409293

實際上,JDK環境配置好之後,選擇一個適合作業系統的Eclipse版本,啟動Eclipse就能根據

環境變數自動尋找JDK,併成功執行。

下面是我的彎路歷程,總結一下,希望別人可以少走彎路。

 

我安裝前手頭的環境

=========================================================================

作業系統 win7 64bit

JDK:jdk-7u3-windows-i586

http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u3-download-1501626.html

Eclipse:eclipse-SDK-4.1-win32-x86_64

http://www.eclipse.org/downloads/

=========================================================================

先把jdk安裝上,然後設定好java環境後,test沒有問題

然後把Eclipse解壓開,然後進入Eclipse目錄中雙擊 eclipse 時

啟動不開,報 Failed to load the JNI shared library jvm.dll 錯誤。

網上查閱 http://www.oschina.net/question/12_26790

指點 換成 64位的jdk,就能解決

於是乎,下載64位jdk  jdk-7u3-windows-x64

安裝好後,仍然報這個錯誤,

接下來把之前安裝的32位的java環境刪掉(開始,控制面板,解除安裝程式,32位java環境相關軟體)

再啟動Eclipse,終於正常了。

How to reconfigure eclipse to use a 64 bit JVM

 

I'm using eclipse on what I thought were all 64 bit runtime environments.

The current settings Java>installed JREs and Execution Environment all point to jdk1.6.0_30 which is a 64 bit version of the JDK.

However, eclipse still thinks it's running a 32 bit version because when I run:

System.getProperty("sun.arch.data.model");

 

it returns 32 instead of 64.

And the external JNI resource that I compiled for 64 bit machines will not link to the shared .so file unless it's running in a 64 bit enviroment. (I'm getting word size mismatch errors when I try to do this)

So How can I reconfigure eclipse to run 64 bit jvm. Does eclipse itself have to be a 64 bit version?

:on linux

Edit: I have tried everyone's suggestions and nothing is working. I've changed the execution, and enviroment variables to point to the newst JDK I have which is 1.6_30. when I run the program from a command line I get 64 and amd64 as the value when I run the same program in eclise I get 32 and i386. Something is wrong in eclipse that is causing it to try and run it on a 32 bit JVM. when I try java -d32 -version it says that a 32 bit enviroment isn't installed but Eclipse doesn't know that. I've modified the Eclipse.ini file and still nothing is working. I've restarted eclipse after these changes...nothing. Can some one who knows eclipse well people help me out here. thanks

Add the -vm tag to eclipse.ini or the shortcut to explicitly specify a JRE. Note that the default for Windows XP is to use the CRAPPY JRE that comes with Windows.

-vm "%JAVA_HOME%/bin/javaw.exe"

Note

that the format in eclipse.ini is to have -vm on one line and the value on the next.. I'm not sure why... 

-Xmx8g
-d64

 

The "installed JREs" (better use JDKs) are used for building and running your code

and can be of different architecture or Java version.

The JVM used for running Eclipse is defined in the eclipse.ini file.

You should use the version for the architecture of the JVM.

複製程式碼

Okay. 
This has been rather headache inducing, but I believe I have a solution. 
After changing the eclipse.ini, Go to your project properties. 
Under the Run/Debug settings, edit the launch configuration for your project. 
Under the JRE tag, click installed JREs. 
When that dialog comes up, click search. 
Go to your program files folder, NOT the x86 one, and let it search for your JREs. 
When the latest comes up, deselect the JRE that was currently selected and select the most recent JRE that it found. 
I renamed mine JRE7-64 just so I could identify a difference. This solved the issue on my end. Good luck

複製程式碼