Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

jython and java application

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


keith at nekotaku

Nov 25, 2009, 5:30 PM

Post #1 of 7 (438 views)
Permalink
jython and java application

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.
--
http://mail.python.org/mailman/listinfo/python-list


kursat.kutlu at gmail

Nov 25, 2009, 5:54 PM

Post #2 of 7 (405 views)
Permalink
Re: jython and java application [In reply 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

On Nov 26, 3:30 am, KB <ke...@nekotaku.com> wrote:
> 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.

--
http://mail.python.org/mailman/listinfo/python-list


python at mrabarnett

Nov 25, 2009, 5:54 PM

Post #3 of 7 (405 views)
Permalink
Re: jython and java application [In reply to]

KB wrote:
> 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.

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?).
--
http://mail.python.org/mailman/listinfo/python-list


keith at nekotaku

Nov 25, 2009, 6:49 PM

Post #4 of 7 (400 views)
Permalink
Re: jython and java application [In reply 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.
--
http://mail.python.org/mailman/listinfo/python-list


kursat.kutlu at gmail

Nov 25, 2009, 7:20 PM

Post #5 of 7 (418 views)
Permalink
Re: jython and java application [In reply 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



On Nov 26, 4:49 am, KB <ke...@nekotaku.com> wrote:
> 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.

--
http://mail.python.org/mailman/listinfo/python-list


keith at nekotaku

Nov 25, 2009, 7:33 PM

Post #6 of 7 (364 views)
Permalink
Re: jython and java application [In reply 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!
--
http://mail.python.org/mailman/listinfo/python-list


kursat.kutlu at gmail

Nov 25, 2009, 7:40 PM

Post #7 of 7 (364 views)
Permalink
Re: jython and java application [In reply to]

Welcome a million :)

On Nov 26, 5:33 am, KB <ke...@nekotaku.com> wrote:
> 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!

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.