>>> import sys
>>> sys.path.append("/usr/local/oanda_fxtrade.jar") # add the jar to your path
>>>
>>> import com.oanda.fxtrade.api.test.Example1 as main1
>>> import com.oanda.fxtrade.api.test.Example2 as cancel
main1("JPY",9,'-1')
TypeError: main1("JPY",9,'-1'): expected 0 args; got 3
这似乎没有错误 - 但实际上我需要一些参数
取消()
线程[线程-0,5,主]
Java类内部
public final class Example1 extends Thread {
private Example1() {
super();
}
public static void main(String[] args) throws Exception {
FXClient fxclient = API.createFXGame();
String username = "foo";
String password = "foo";
String sel=args[0];
String str1=args[1];
String str2=args[2];
main1.main("日元9 -1")
类型错误:main():第一个参数无法强制转换为 String[]
好吧,我想我已经进入了一个新的水平
最佳答案
之后
import com.oanda.fxtrade.api.test.Example1 as main1
main1 是类。在java中,执行类将运行main,但这并不意味着您可以将参数传递给类。
尝试:
main1.main(["JPY","9","-1"])
编辑: 这里有两个不同的问题。
对于随后的错误无法初始化类com.oanda.fxtrade.api.API
...看起来您应该检查这个问题:Why does Jython refuse to find my Java package?
调用 sys.path.append 添加 jar 不允许包扫描器在加载时进行操作。您应该尝试手动导入所需的模块/类,或者在调用 jython 之前将 jar 添加到 CLASSPATH 中。
从这里我认为 jython 答案已经存在,它变成了一个 com.oanda.fxtrade.api 问题,可能超出了 SO 范围。
关于java - Jython:包括自定义 Java 类 [oanda],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11320514/