简体   繁体   English

设置Eclipse IDE启动的环境变量

[英]Setting Environment variables for Eclipse IDE launching

I want to start a project in eclipse, but when I try to start eclipse, it doesn't open. 我想在eclipse中启动一个项目,但是当我尝试启动eclipse时,它无法打开。 My instructor said I'd have to set the environment variables. 我的老师说我必须设置环境变量。 What is the importance of environment variables like PATH , CLASSPATH , JAVAHOME and what are their correct values? 环境变量如PATHCLASSPATHJAVAHOME的重要性是什么?它们的正确值是什么?

So that Eclipse will know where Java is. 这样Eclipse就会知道Java的位置。

JAVA_HOME is not used by Java itself. Java本身不使用JAVA_HOME Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. 某些第三方程序(例如Apache Tomcat)期望将其中一个环境变量设置为JDK或JRE的安装目录。 If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME. 如果您没有使用需要它们的软件,则无需设置JAVA_HOME和JRE_HOME。

CLASSPATH is an environment variable which contains a list of directories and / or JAR files, which Java will look through when it searches for Java classes to load. CLASSPATH是一个环境变量,它包含目录和/或JAR文件的列表,Java在搜索要加载的Java类时将查看这些文件。 You do not normally need to set the CLASSPATH environment variable. 您通常不需要设置CLASSPATH环境变量。 Instead of using this environment variable, you can use the -cp or -classpath option on the command line when using the javac and java commands. 使用javac和java命令时,可以在命令行上使用-cp或-classpath选项,而不是使用此环境变量。

PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. PATH是操作系统(Windows,Mac OS X,Linux)使用的环境变量,它将查找要运行的本机可执行程序。 You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. 您应该将JDK安装目录的bin子目录添加到PATH,以便可以在命令提示符窗口中使用javac和java命令以及其他JDK工具。 The JDK installation instructions explain how to set PATH. JDK安装说明解释了如何设置PATH。

Source 资源

Eclipse IDE itself uses Java to start and run. Eclipse IDE本身使用Java来启动和运行。 On windows you should have something called environment variables like PATH and JAVA_HOME, where locations of programs can be stored. 在Windows上你应该有一些叫做PATH和JAVA_HOME的环境变量,可以存储程序的位置。 In case of Java it can be very convenient, because when you have different versions, all you have to do is to edit your PATH or your JAVA_HOME. 在Java的情况下它可以非常方便,因为当你有不同的版本时,你所要做的就是编辑你的PATH或你的JAVA_HOME。 If you don't set those variables then, programs like Eclipse might not know what to use. 如果你没有设置那些变量那么像Eclipse这样的程序可能不知道要使用什么。

Classpath is slightly different because that's what your java program uses, you'll learn more about it when you will get some experience in java programming. Classpath略有不同,因为这是你的java程序使用的,当你获得一些java编程经验时,你会学到更多关于它的知识。

As I understand your question, you are having problems with starting Eclipse? 据我了解你的问题,你在启动Eclipse时遇到了问题? If so, you have most likely not a correct path to the JRE/JDK. 如果是这样,您很可能没有正确的JRE / JDK路径。 See this FAQ for help . 请参阅此FAQ以获取帮助

In short, you typically want to set your PATH variable to point to the java executable. 简而言之,您通常希望将PATH变量设置为指向java可执行文件。 Note that Eclipse does not use JAVA_HOME at all. 请注意,Eclipse根本不使用JAVA_HOME

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

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