[英]Running a java program using -cp
so I've checked many posts here and tried everything people suggested and I'm still getting "Could not find or load main class" error, and my professor wasn't very helpful in his answer when I asked for help. 所以我在这里检查了很多帖子并尝试了人们建议的所有内容,我仍然得到“无法找到或加载主要课程”的错误,当我寻求帮助时,我的教授对他的回答并不是很有帮助。
This is what my professor said is supposed to work (he is using OSX). 这就是我的教授所说的应该工作(他正在使用OSX)。
java -cp classes:lib/json.jar cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
After reading some other posts on this site, I also tried: 在阅读本网站上的其他帖子后,我也尝试过:
java -cp classes:"lib/json.jar" cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
java -cp "lib/json.jar" cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
Still nothing works. 仍然没有任何作用 I'm in the base directory in a bash prompt ~\\GroupJsonRPC and the class file that is in ~\\GroupJsonRPC\\classes\\cst420\\jsonrpc\\client\\GroupServerJavaStub.class exists and is ready for running.
我在bash提示符〜\\ GroupJsonRPC的基本目录中,〜\\ GroupJsonRPC \\ classes \\ cst420 \\ jsonrpc \\ client \\ GroupServerJavaStub.class中的类文件存在并准备好运行。 The same goes for ~\\GroupJsonRPC\\lib\\json.jar.
〜\\ GroupJsonRPC \\ lib \\ json.jar也是如此。 Any insight into how to get this darn thing running would be greatly appreciated!
任何洞察如何让这个运行的东西运行将非常感谢!
PS: I'm using Windows. PS:我正在使用Windows。
The proper command is: 正确的命令是:
java -cp "classes;lib/json.jar" cst420.jsonrpc.client.GroupServerJavaStub http://127.0.0.1:8080
You need to be sure to include the directory of your class files as well as the jar file(s) with ';' 您需要确保包含类文件的目录以及带有';'的jar文件 separators, and don't use the
-jar
option. 分隔符,不要使用
-jar
选项。 It invalidates the -cp
option. 它使
-cp
选项无效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.