我在哪里以及如何保存jdk链接以便打开eclipse?

时间:2014-08-11 01:46:56

标签: java eclipse

当我打开eclipse时,它会给我一个运行时错误,说明JDK的路径不正确。

我不知道在哪里保存链接,以便我可以打开它

2 个答案:

答案 0 :(得分:1)

首先在您的电脑上安装Java:它应该在C:\ Program Files中创建Java文件夹。

您必须像这样设置Classpath:

Set the CLASSPATH environment variable

    (for **Windows NT/2000/XP**)

1. At the left bottom corner of your computer desktop, choose Start -> Setting -> Control Panel, and double-click System

2. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows 
2000/XP select the Advanced tab and then Environment Variables.

3. For either User variables or System variables, click New and in the popup window, enter Variable name as CLASSPATH (note that all letters should be capital), and the directory where your JDK is installed as the Variable value.

For example:

If your JDK is installed at: C:\jdk1.4.1_06

Put the following line as the value:

C:\jdk1.4.1_06\bin;C:\jdk1.4.1_06\jre\bin;.

The first is where the java compiler 'javac' is, the second is the java run time environment 'java' is, and the final '.' denotes your working directory, so that the compiler and jre will find where your programs are.  To be safe, you may also want to append the above line to then end of your PATH variable. Use ';' as the separator.

Save the variables, test the setting by opening a DOS prompt, type in

echo %CLASSPATH%

If your environment variables are set correctly, you should see your settings.

Or, you can just type in 

javac

java

If your PATH and CLASSPATH is correct, windows should recognize those commands.

You do NOT need to restart your computer when installing Java.

Check whether TextPad and Java SDK work on your computer
    Download HelloWorld.java into your local drive. Be sure that filename is case sensetive in JAVA programming.
    Start TextPad, and open this HelloWorld.java file.
    Click menu "Tools" ---> "Compile Java" to compile java file.
    Click menu "Tools" ---> "Run Java Application" to run this file.

If you see "Hello World" in a DOS PROMPT window, that means there is no problem with your TextPad to compile/run Java program. Congratulations. You can start your java programming now. If you see some errors when run Java program, please click here to get more information.
For a more comprehensive description on how to setup Java environment on Windows machinese, please refer to the Sun document at: http://java.sun.com/j2se/1.4.2/install-windows.html

For **windows 7**: Follow this link http://www.abodeqa.com/2012/08/11/how-to-set-path/

然后:启动兼容的eclipse(例如64位操作系统上的64位eclipse)。

在Eclipse中,选择Windows |首

单击Java前面的+或双击Java(在+后面)

单击已安装的JRE

在“名称”列下,双击“jre1.5.0_08。”

单击Add External Jars ...按钮。

在Jar Selection窗口中,导航到您的工作区文件夹,然后双击文件cs15-1xx.library。

在“编辑JRE”窗口中,单击“确定”

在“已安装的JRE”窗口中,单击“确定”

终止(X)欢迎窗口 您可以通过选择帮助|来获取它欢迎

终止(X)Eclipse窗口。

有关详细信息,请按照http://blog.ajduke.in/2013/04/28/setting-up-new-java-compiler-and-runtime-in-eclipse-ide/

进行操作

答案 1 :(得分:0)

使用-vm命令行参数(通过快捷方式或在eclipse.ini文件中)启动eclipse时,可以指定目标JRE。

  • 命令行语法:eclipse -vm c:\jre\bin\javaw.exe
  • eclipse.ini文件语法(使用2行
-vm
c:/jre/bin/javaw.exe

您也可以在eclipse安装目录下复制给定版本的JRE。

一般来说,我会真的建议不要将%JAVA_HOME%/ bin添加到您的SYSTEM路径。根据我的经验,这通常会导致许多意外行为。更好的IMHO设置JAVA_HOME并通过脚本/命令行/快捷方式/等将其/ bin目录添加到PATH。并在需要时调用它们。