如何将 jar 文件添加到类路径? [英] How do I add jar files to the Classpath?
问题描述
我在 Windows
上,我尝试了 javac
下的 -classpath
无济于事.还尝试将 jar 移动到 src 目录,但 java 文件仍然无法编译.尝试在脚本中简单地导入 httpclient.
I'm on Windows
and I've tried the -classpath
under javac
to no avail. Also tried moving the jar to the src directory, but java file still won't compile. Trying to do a simple import of httpclient in the script.
import org.apache.http.client.*;
推荐答案
安装您的 JDK 并不管它.不要将 .jar 文件复制到 JDK 文件夹中!
Install your JDK and leave it alone. Do not copy .jar files into your JDK folders!
如果您还没有 IDE,我建议您使用 Eclipse 或 Netbeans 之类的 IDE.
I'd recommend getting an IDE like Eclipse or Netbeans, if you don't already have one.
我将设置一个新项目,创建或导入您的源代码,并为该项目设置一个类路径.
I would set up a new project, create or import your source, and set a class path for the project.
如果这不起作用,请告诉我们:
If that doesn't work, please tell us:
a) 您的操作系统和版本
a) your OS and version
b) 你的 JDK 和版本
b) your JDK and version
c) 你的 IDE
d) 剪切/粘贴确切的错误信息
d) cut/paste the EXACT error message
e) 剪切/粘贴相关代码
e) cut/paste the relevant code
这篇关于如何将 jar 文件添加到类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!