简体   繁体   English

我不知道如何从命令行调用Java oscar3类方法stringToString

[英]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.

相关问题 无法找出正确的参数形式-从Java的静态嵌套类中调用方法 - Can't figure out correct argument form - calling a method from within a static nested class in Java Java新手无法弄清楚如何使用绘画方法 - New to java can't figure out how to use paint method 我正在尝试制作一个在命令行上播放的跳棋游戏,我不知道如何根据用户输入移动棋子 - I am trying to make a checkers game that plays on the command line, I can't figure out how to move the piece based on the users Input 尝试使用对象调用方法,但无法找出要放入的参数 - Trying to call a method with an object, but can't figure out arguments to put Java:无法弄清楚如何使用class.getClassLoader()。getResourceAsStream(),因此在构建工件时可以使用 - Java: Can't figure out how to use class.getClassLoader().getResourceAsStream() so it works when i build artifacts 我不知道如何在第四种方法中打印出第三种方法 - I can't figure out how to get the third method to print out in the fourth method 从Java中的行号中找出方法名称? - Figure out method name from line number in Java? java 代码的简单行正在捕获 UnsupportedEncodingException,我不知道为什么 - Simple line of java code is catching a UnsupportedEncodingException and I can't figure out why Java-从命令行调用方法 - Java- Call a method from the command line 如何在JAVA中从父类的内部类中调用子类中的重写方法? - How can I call the overridden method in a child class from a parent class's inner class in JAVA?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM