1
  >>> 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

This seems no error - but really i need some args

cancel()
Thread[Thread-0,5,main]

Inside java class

  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("JPY 9 -1")

TypeError: main(): 1st arg can't be coerced to String[]

Ok I think I went to the next level

1 Answers1

1

After

import com.oanda.fxtrade.api.test.Example1 as main1

main1 is the class. In java executing the class will run main but that doesn't mean you can pass args to the class.

Try:

main1.main(["JPY","9","-1"])

EDIT: There were two separate issues here.

For the subsequent error Could not initialize class com.oanda.fxtrade.api.API... it looks like you should review this question: Why does Jython refuse to find my Java package?

calling sys.path.append to add the jar does not allow the package scanner operate which happens at load time. You should try either importing the required modules/classes manually or perhaps adding the jar to the CLASSPATH before invoking jython.

from here I think the jython answer is in and it becomes a com.oanda.fxtrade.api question with is probably outside SO scope.

Community
  • 1
  • 1
Phil Cooper
  • 5,747
  • 1
  • 25
  • 41