473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JPype - passing to Java main

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

=============JA VA============
package com;

public class JPypeTest {

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

public void printArgument(S tring arg) {
System.out.prin tln(arg);
}
}

===========PYTH ON===========
from jpype import *

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

com = JPackage("com") ;
jp = com.JPypeTest() ;
jp.printArgumen t('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 4817
un************* ***@gmail.com wrote:
I am trying to get JPype to pass a String into a Java class main
function. Demonstration code below:

=============JA VA============
package com;

public class JPypeTest {

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

public void printArgument(S tring arg) {
System.out.prin tln(arg);
}
}

===========PYTH ON===========
from jpype import *

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

com = JPackage("com") ;
jp = com.JPypeTest() ;
jp.printArgumen t('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.m ain("arg")

Ian

Aug 13 '07 #2
>
Try this:
com.JPypeTest.m ain("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.m ain("arg")
RuntimeError: No matching overloads found. at src/native/common/
jp_method.cpp:1 21
----------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.m ain("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.m ain("arg")
RuntimeError: No matching overloads found. at src/native/common/
jp_method.cpp:1 21
----------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.m ain(["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************ *********@d55g2 000hsg.googlegr oups.com>,
<un************ ****@gmail.comw rote:
>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.m ain("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.m ain(["arg"]).

Gary Duzan
Motorola HNM
>On Aug 14, 8:03 am, Laurent Pointal <laurent.poin.. .@limsi.frwrote :
>unlikeablePorp o...@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
3761
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 funny, at least for me. I guess dev'ing a GUI in a test-driven way is not possible, or is it? I'm using wxPython, so if anyone has an idea... For now most of the time I extend and change the gui things, then run it, do the clicks to go thru the...
14
2853
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 written in Python, using the standard libraries and several extension modules, I am trying to gauge the viability of integration with
3
2290
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 this been done before for with jython? Another approach would be to use JPype to call the jython jar directly. My goal is to be able to script Java code using Jython - but with the twist of using Cpython as a glue layer. This would allow...
4
2662
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); jep.runScript("C:\\temp\\testscript.py"); jep.close();
0
1069
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 loaded : 26 JVM has been shutdown
1
5105
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 to business intelligence tools (JasperReports, Mondrian, Pentaho, etc) for which we don't have analogous tools in cpython yet. My idea it to use jpype in a cherrypy application server to tie these java BI tools into a website interface without...
3
4187
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 but when i wrote a short script: " from jpype import *
1
3189
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 windows/linux/mac osx. On the other hand, there is a living package(http://www.jfree.org/jfreechart) for java, and it is nice. So what about make the interface to JFreeChart via jpype(http://jpype.sourceforge.net), or rewrite JFreeChart in and for Python to...
1
6374
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 that? JPype? http://sourceforge.net/projects/jpype
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.