Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jython and java application

10 views
Skip to first unread message

KB

unread,
Nov 25, 2009, 8:30:19 PM11/25/09
to
Hi there,

Apologies if this is on the wrong group, this is a jython question.
Please redirect me to the correct group if this is in error.

I have a java application that takes no arguements. When I run it, it
spits out output, and finishes.

I am trying to run this java application from jython 2.5.1, JRE6.

I have made simple "Hello World" java classes be callable from a
simple jython script, yet I am stumbling on the java main construct in
the application.

print krbtest.SimpleHistoricTutorial().main() obviously gives me an
args error (expected 1, got 0) as the definition in the java
application is:

public static void main(String[] args)

The jython code is as follows:
import krbtest

# was messing with this to pass a java formatted string but to no
avail

from java.lang import String

print krbtest.SimpleHistoricTutorial().main()

#####

Any advice greatly appreciated! Especially with how to call "main()"
with arguments from jython.

Apologies in advance again if this is the wrong group.

ShoqulKutlu

unread,
Nov 25, 2009, 8:54:23 PM11/25/09
to
I don't know if it's right place but normally main method requires an
args even it is not needed to supply from commandline. Maybe this is a
jython runtime error and requires at least an empty argument. You
could try to pass and empty string array like ['']. I'm not using
jython please use your own notation.

Regards,
Kutlu

MRAB

unread,
Nov 25, 2009, 8:54:43 PM11/25/09
to pytho...@python.org

I don't know jython, but from the look of it I'd say that you need to
give main() some kind of argument, such as a string or an empty list.
(If you pass an empty jython list to a Java method that's expecting an
array of String, will the Java method receive a zero-length array of
String?).

KB

unread,
Nov 25, 2009, 9:49:15 PM11/25/09
to

Hmmm, for some reason my follow up post didn't make it.

Modified jython script to:

# Eclipse package name for java application
import krbtest

import java.lang as lang
from java.lang import String
from jarray import array

myargs=array([],String)

krbtest.SimpleHistoricTutorial().main(myargs)
****

Now I get:

Traceback (most recent call last):
File "test.py", line 15, in <module>
krbtest.SimpleHistoricTutorial().main(myargs)
at krbtest.SimpleHistoricTutorial.run(SimpleHistoricTutorial.java:27)

at krbtest.SimpleHistoricTutorial.main(SimpleHistoricTutorial.java:
22)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)


java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: com/
bloomberglp/blpapi/Session


I would post the java app but its quite large, but the main defn:

public static void main(String[] args) throws Exception
{
SimpleHistoricTutorial example = new SimpleHistoricTutorial();
example.run();
}


Is pretty vanilla. I have tried making the run() a public method and
call it, all to no avail.

Note, the Java app works fine standalone, I just need to call it from
jython.

Again, any help appreciated.

ShoqulKutlu

unread,
Nov 25, 2009, 10:20:44 PM11/25/09
to
Hi,

I don't know how do you call the java library from within your jython
application it gives java.lang.NoClassDefFoundError
This looks like you referenced jar or whatever else from your jython
application which also needs a class com/bloomberglp/blpapi/Session
in another library file. It might run while running standalone because
the dependent libraries exists where it looks for. For your jython
application you need to make krbtest referenced to the dependent
libraries. It seems you application took a copy of krbtest and other
libraries not available to krbtest there. I hope it helps.

Regards,
Kutlu

KB

unread,
Nov 25, 2009, 10:33:02 PM11/25/09
to
Kutlu,

I already have a first born, else I would name her after you.

You are brilliant. That's what it was. Kudos.

For future ref for fellow boneheads like me, in Eclipse, under Project
properties, Jython Class Path, Add External JAR...

Thanks a million!

ShoqulKutlu

unread,
Nov 25, 2009, 10:40:01 PM11/25/09
to
Welcome a million :)
0 new messages