[英]I can't figure out how to call Java oscar3 class method stringToString from the command line
I'm trying to call a Java class method from the command line but the for the life of me can't figure out the syntax. 我正在尝试从命令行调用Java类方法,但是对于我而言,我无法弄清楚语法。 The method is stringToString found in this class http://apidoc.ch.cam.ac.uk/oscar3/apidocs/uk/ac/cam/ch/wwmm/oscar3/Oscar3.html
该方法是在此类http://apidoc.ch.cam.ac.uk/oscar3/apidocs/uk/ac/cam/ch/wwmm/oscar3/Oscar3.html中找到的stringToString
What I have tried: 我试过的
java -Xmx512m -classpath .:oscar3-a5:lib/oscar3-a5.jar uk.ac.cam.ch.wwmm.oscar3.Oscar3 stringToString "test"
java -Xmx512m -classpath .:oscar3-a5:lib/oscar3-a5.jar uk.ac.cam.ch.wwmm.oscar3 Oscar3(stringToString "test)
java -classpath .:oscar3-a5.jar:lib/uk.ac.cam.ch.wwmm.oscar3.Oscar3 stringToString "test"
It complains like this: 它抱怨像这样:
Exception in thread "main" java.lang.NoClassDefFoundError: uk/ac/cam/ch/wwmm/oscar3/Oscar3
Caused by: java.lang.ClassNotFoundException: uk.ac.cam.ch.wwmm.oscar3.Oscar3
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I have also looked at this ( Java: how to import a jar file from command line ) for a solution but clearly I'm too retarded to see the obvious. 我也已经看过这个( Java:如何从命令行导入jar文件 )作为解决方案,但显然我太有能力了,看不见明显的东西。 If anyone knows the correct syntax for this any help would be great.
如果有人知道正确的语法,那么对您有帮助。
You are very close! 你很亲密! I think you want the following:
我认为您需要以下条件:
java -Xmx512m -cp oscar3-a5/oscar3-a5.jar uk.ac.cam.ch.wwmm.oscar3.Oscar3 stringToString test
Alternatively if your current working directory ( pwd
) is the same directory that oscar3-a5.jar
resides in, then: 或者,如果您当前的工作目录(
pwd
)与oscar3-a5.jar
所在的目录相同,则:
java -Xmx512m -cp ./oscar3-a5.jar uk.ac.cam.ch.wwmm.oscar3.Oscar3 stringToString test
(I've assumed you're running on *nix - if you're running on Windows replace the /
with \\
) (我假设你在* nix运行-如果你在Windows上运行的替换
/
与\\
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.