简体   繁体   English

如何将.jar文件添加到Javac编译(Windows 10)

[英]How to add .jar files to javac compilation (Windows 10)

I am tryin to compile my java classes like this at the moment with javac 我正在尝试用javac编译这样的java类

javac myClass.java

I am also using some .jar files (poi-3.15.jar...), which are necessary for classes such as Row, HSSFSheet and so on (for getting information from excel). 我还使用了一些.jar文件(poi-3.15.jar ...),这些文件对于Row,HSSFSheet等类(从Excel获取信息)是必需的。 If I loaded these .jar files into Eclipse, I had no problem getting things working. 如果将这些.jar文件加载到Eclipse中,则可以正常工作。

However, using the command prompt, my .jar files are not found. 但是,使用命令提示符,找不到我的.jar文件。 I've put my .java files in the /src folder and .jar files to where my .classpath is. 我将.java文件放在/ src文件夹中,并将.jar文件放到.classpath所在的位置。 The compilation doesn't work. 编译不起作用。

Is it possible to place .java and .jar files into the same folder, successfully execute "javac" command and then execute the program. 是否可以将.java和.jar文件放置在同一文件夹中,成功执行“ javac”命令,然后执行该程序。

I need to send my homework to a teacher, so the only thing he has to do is run the "javac myClass.java", following with "java myClass". 我需要将作业发送给老师,因此他唯一要做的就是运行“ javac myClass.java”,后跟“ java myClass”。

Any help is much appreciated! 任何帮助深表感谢!

To include jars, use: 要包括罐子,请使用:

javac -classpath "/path/to/jar1.jar;/parh/to/jar2.jar" MyClass.java

This will add jars to your classpath at compile time. 这将在编译时将jar添加到您的类路径中。

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

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