Java environment variables and their functionality
Concrete Operating Steps:
As all the env variables will involve the directory of jdk, we can set the JAVA_HOME first. Then we can use the %JAVA_HOME% make other env variables setting simple.
- JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21
- PATH=%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
- CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
Explanations of Functionalities:
1. PATH env variable
It is used to search the command directory when we use the console type commands. We only can use the javac and java command anywhere after the jdk\bin and jdk\jre\bin directory have been added in to the PATH env variable.
E.g. "C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files\Java\jdk1.6.0_21\jre\bin", the ';' is the separator between env variables.
2. CLASSPATH env variable
It is used to search the known classes, which include the default classes used by JVM and the current classes we created. Thus we add '.' directory including the classes in current directory, and the jdk\lib\dt.jar and jdk\lib\tools.jar including the default classes JVM will use.
E.g. ".;C:\Program Files\Java\jdk1.6.0_21\lib\dt.jar;C:\Program Files\Java\jdk1.6.0_21\lib\tools.jar".
3. JAVA_HOME env variable
It is used to indicate the directory of jdk. Many softwares like Eclipse, NetBeans, Tomcat will use this env variable to execute jdk.
E.g, "C:\Program Files\Java\jdk1.6.0_21".
For Tomcat web app deploying, the eclipse's export may cause one tiny issue in MacBook Pro:
It's better NOT to choose "Optimize for a specific server runtime" item, which may cause the 404 error in Tomcat server.
Eclipse的项目文件夹和workspace文件夹
在迁入代码的时候,特别是从以前的SVN系统,分辨Eclipse项目和Eclipse的workspace是一件让人气恼的事情。一般来讲,版本控制下的项目,都是一个个的Eclipse项目。而识别它是Eclipse项目根目录的依据是看“.myeclipse和.settings”文件夹是否存在。
你还不可以直接使用这个项目,必须在你本地机器上的一个workspace中。
一个让人头痛的问题是,很容易把项目的根目录(也就是.myeclipse所在的文件夹,例如把它命名为ProjectRoot)一并当做workspace去使用。这只会造成整个项目的编译失败。你的ProjectRoot文件夹,必须放在workspace文件夹里面。
而识别workspace根目录的依据是看“.metadata”文件夹是否存在。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)