472,950 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

JPype - passing to Java main

I am trying to get JPype to pass a String into a Java class main
function. Demonstration code below:

=============JAVA============
package com;

public class JPypeTest {

public static void main(String args[]) {
System.out.println(args[0]);
}

public void printArgument(String arg) {
System.out.println(arg);
}
}

===========PYTHON===========
from jpype import *

startJVM("C:/Program Files/Java/jdk1.5.0_12/jre/bin/server/jvm.dll","-
Djava.class.path=C:/jpypetest/test/")

com = JPackage("com");
jp = com.JPypeTest();
jp.printArgument('XXXX');
#WANT TO CALL main("arg") HERE!!!!
shutdownJVM()
===============================

What I want is to be able to call main() with an argument from the
python file (using JPype) and have it echo
args[0]. I can get this to work for printArgument(), but not for
main().

Thanks,
Sarah

Aug 13 '07 #1
6 4787
un****************@gmail.com wrote:
I am trying to get JPype to pass a String into a Java class main
function. Demonstration code below:

=============JAVA============
package com;

public class JPypeTest {

public static void main(String args[]) {
System.out.println(args[0]);
}

public void printArgument(String arg) {
System.out.println(arg);
}
}

===========PYTHON===========
from jpype import *

startJVM("C:/Program Files/Java/jdk1.5.0_12/jre/bin/server/jvm.dll","-
Djava.class.path=C:/jpypetest/test/")

com = JPackage("com");
jp = com.JPypeTest();
jp.printArgument('XXXX');
#WANT TO CALL main("arg") HERE!!!!
shutdownJVM()
===============================

What I want is to be able to call main() with an argument from the
python file (using JPype) and have it echo
args[0]. I can get this to work for printArgument(), but not for
main().

Thanks,
Sarah
Try this:
com.JPypeTest.main("arg")

Ian

Aug 13 '07 #2
>
Try this:
com.JPypeTest.main("arg")

Ian
Thanks for your suggestion, but it doesn't work (produces an error).

Does anybody else have any ideas?

Thanks,
Sarah

Aug 14 '07 #3
un****************@gmail.com a écrit :
>Try this:
com.JPypeTest.main("arg")

Ian

Thanks for your suggestion, but it doesn't work (produces an error).
This is where you should have copy/pasted the error.

;-)
>
Does anybody else have any ideas?
Sorry, no.

Aug 14 '07 #4
Good point Laurent. Here is the error produced when I try to access
main() using
'com.JPypeTest.main("arg")'

The original code is pasted at the top of this thread. I only added
'com.JPypeTest.main("arg")' which causes the error below

-------------ERROR_-------------
File "tester.py", line 10, in <module>
com.JPypeTest.main("arg")
RuntimeError: No matching overloads found. at src/native/common/
jp_method.cpp:121
----------END ERROR-------------

Thanks,
Sarah

On Aug 14, 8:03 am, Laurent Pointal <laurent.poin...@limsi.frwrote:
unlikeablePorpo...@gmail.com a écrit :
Try this:
com.JPypeTest.main("arg")
Ian
Thanks for your suggestion, but it doesn't work (produces an error).

This is where you should have copy/pasted the error.

;-)
Does anybody else have any ideas?

Sorry, no.

Aug 14 '07 #5
-------------ERROR_-------------
File "tester.py", line 10, in <module>
com.JPypeTest.main("arg")
RuntimeError: No matching overloads found. at src/native/common/
jp_method.cpp:121
----------END ERROR-------------
I haven't used jpype, but the signature for java main functions is

public static void main (String [] args)

So try com.JPypeTest.main(["arg"])

Note the addition of square brackets to create a *list* of arguments,
which presumably jpype will transform into a java String[].

Alan.

Aug 14 '07 #6
In article <11*********************@d55g2000hsg.googlegroups. com>,
<un****************@gmail.comwrote:
>Good point Laurent. Here is the error produced when I try to access
main() using
'com.JPypeTest.main("arg")'

The original code is pasted at the top of this thread. I only added
'com.JPypeTest.main("arg")' which causes the error below

-------------ERROR_-------------
File "tester.py", line 10, in <module>
com.JPypeTest.main("arg")
RuntimeError: No matching overloads found. at src/native/common/
jp_method.cpp:121
----------END ERROR-------------

Thanks,
Sarah
Just a guess, but try com.JPypeTest.main(["arg"]).

Gary Duzan
Motorola HNM
>On Aug 14, 8:03 am, Laurent Pointal <laurent.poin...@limsi.frwrote:
>unlikeablePorpo...@gmail.com a écrit :
>Try this:
com.JPypeTest.main("arg")
>Ian
Thanks for your suggestion, but it doesn't work (produces an error).

This is where you should have copy/pasted the error.

;-)
Does anybody else have any ideas?

Sorry, no.


Aug 15 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so...
14
by: Joachim Boomberschloss | last post by:
Hello, I am working on a project in Python, and I"m currently looking into the possibiliy of writing some of the project"s modules in Java. Given that a large part of the code is already...
3
by: Jim Hargrave | last post by:
I've read that it is possible to compile jython to native code using GCJ. PyLucene uses this approach, they then use SWIG to create a Python wrapper around the natively compiled (java) Lucene. Has...
4
by: skn | last post by:
Hello, I have written a very simple java class file, which invokes a Python script using JEP. Code snippet:- ------------------- Jep jep = new Jep(false);...
0
by: skn | last post by:
Hello, Is there any option to suppress the JVM activity report that gets displayed, when you execute Java APIs from within Python using JPype. E.g., JVM activity report : classes...
1
by: benchline | last post by:
I have been trying out jpype for python to java work and love it. It works great on my gentoo box with the java 1.4.2 blackdown sdk. I am now trying it on Red Hat Enterprise Linux 3 for access...
3
by: kelemen.viktor | last post by:
Hello! Im a quite newbie in the python world. I have some problem with packages, i installed the jpype package according to its intructions. To test ive written: everything worked correctly...
1
by: oyster | last post by:
As you may know, there is no beautiful and free chart(not plot, you can find the examples at http://www.jfree.org/jfreechart, http://www.rmchart.com) module for python than runs on...
1
by: RC | last post by:
Dear Python Experts/Programmers, I'm going to write a Python program to access some Java class methods from our *.jar file. In your opinion, which way is the good (not the best) way to do...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.