我的代码中有一些编码字符,所以我编译代码如下:
javac -cp cayenne-2.0.4.jar Twokenize.java
Run Code Online (Sandbox Code Playgroud)
没关系.但是当我运行程序时,它会返回一个错误:
java -cp cayenne-2.0.4.jar Twokenize test.txt
Run Code Online (Sandbox Code Playgroud)
这是一个错误:
Error: Could not find or load main class Twokenize
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时:
java Twokenize test.txt
Run Code Online (Sandbox Code Playgroud)
程序(主方法)仍然运行顺利,它满足了需要外部库的代码.请帮我.非常感谢你.
当你使用-cp它时,会丢弃classpath中的当前目录,因此你需要明确指定
使用
java -cp .:cayenne-2.0.4.jar Twokenize test.txt
Run Code Online (Sandbox Code Playgroud)