[英]Run Java Project From Linux Cmd
I've written a java program and I'm trying to run it from cmd both in Windows and Linux. 我已经编写了一个Java程序,并试图在Windows和Linux中从cmd运行它。 I first compiled and then run it , and it worked just fine on Windows.
我先编译然后运行它,它在Windows上运行良好。 The problem comes up when I'm trying to do the same thing on Linux.
当我尝试在Linux上执行相同的操作时,就会出现问题。 The commands I've used on Linux are :
我在Linux上使用的命令是:
javac -cp aspose-cells.jar:aspose-words.jar:aspose-slides.jar ConvertToPdf.java
java -cp aspose-cells.jar:aspose-words.jar:aspose-slides.jar ConvertToPdf
The first command , which starts with javac
, works just fine and outputs the ConvertToPdf.class
file. 第一个命令以
javac
开头,可以正常工作,并输出ConvertToPdf.class
文件。 The problem comes up after running the second one , which outputs the following error: 运行第二个错误后出现此问题,该错误输出以下错误:
Error: Could not find or load main class ConvertToPdf
I'd like to know what am I doing wrong , and I'd be grateful if anyone could point me to the solution. 我想知道我在做什么错,如果有人可以指出我的解决方案,我将不胜感激。 Thanks in advance.
提前致谢。
Add the current directory .
添加当前目录
.
to the classpath: 到类路径:
java -cp aspose-cells.jar:aspose-words.jar:aspose-slides.jar:. ConvertToPdf
your working directory is not included in class path. 您的工作目录不包含在类路径中。 do this :
做这个 :
export CLASSPATH=$CLASSPATH:<your-jars>:.
it should work !!! 它应该工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.