Ves*_*ske 1 command-line gnome-terminal java
所以我试图从终端运行一个 java 文件。但是该文件使用的是 apache.commons.io 库,因此简单的 javac MyFile.java 在这里不起作用。
你如何在终端中包含库?
您首先需要安装libcommons-io-java:
sudo apt-get install libcommons-io-java
Run Code Online (Sandbox Code Playgroud)
然后以javac这种方式使用已安装的 jar 文件:
javac my_file.java -cp /usr/share/java/commons-io.jar
Run Code Online (Sandbox Code Playgroud)
从javac手册页:
Run Code Online (Sandbox Code Playgroud)-cp path or -classpath path Specify where to find user class files, and (optionally) annota? tion processors and source files. This class path overrides the user class path in the CLASSPATH environment variable. If neither CLASSPATH, -cp nor -classpath is specified, the user class path consists of the current directory. See Setting the Class Path for more details.