473,246 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Using python libraries in a Java Program

Hi everyone,
I would like to know if it's possible to use python (libraries) in a
Java Program.
I do not want to use: Process proc = Runtime.getRuntime.exec(command)

I am basically looking for something like the "Reversed" version of
Jython.

Thanks in advance.
-gohaku
Jul 18 '05 #1
3 2130
gohaku wrote:
Hi everyone,
I would like to know if it's possible to use python (libraries) in a
Java Program.
I do not want to use: Process proc = Runtime.getRuntime.exec(command)

I am basically looking for something like the "Reversed" version of Jython.

Thanks in advance.
-gohaku

I think you can use Jython that way. Just compile your module to a
..class file using jythonc, then use it like any other class. If you want
to access python modules put "import org.python.modules.MODULENAME.*" in
your Java program.
Jul 18 '05 #2
Sam Roth wrote:
gohaku wrote:
Hi everyone,
I would like to know if it's possible to use python (libraries) in a
Java Program.
I do not want to use: Process proc = Runtime.getRuntime.exec(command)

I am basically looking for something like the "Reversed" version of
Jython.

Thanks in advance.
-gohaku

I think you can use Jython that way. Just compile your module to a
.class file using jythonc, then use it like any other class. If you want
to access python modules put "import org.python.modules.MODULENAME.*" in
your Java program.


For this to work though, the Python class must implement or extend a
Java interface/class. Otherwise a pure python class compiled to .class
has a very strange interface indeed.

Also, if the needed python module is a native one, or relies on native
code. you're out of luck.

Depending on the type of integration needed, and the type of module to
integrate. I see that you have 2 choices. Either build a simple JNI
module to embed the Python interprter in Java. Expose a few methods like
execfile and you have simple integration that allows you to call any
python module.

Tighter integration would be very difficult indeed. I am currently doing
the same thing, except in reverse (hosting the JVM inside python) and
its a pretty complicated task. I guess you could use my project to host
your whole program in Python, then make callbacks back into ptyhon code
to use the module. Then again, you could do the same using jython ...

Good luck,

Steve
Jul 18 '05 #3
You may look at JPE (Java Python Environment).

It is a Sourceforge project...

Dieter
Jul 18 '05 #4

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

Similar topics

36
by: Tim Churches | last post by:
If a compiled Python extension module B includes code from some other software A which is licensed only under the GPL, do other Python programmes, C, which import module B also need to be licensed...
5
by: Sridhar R | last post by:
Hi, I come across the Parrot project. Seems like it is a better compromising alternative for .NET and Java. That is, we can develop applications in Python (for productivity) and still can...
3
by: rjaw | last post by:
Hi there, using the udb-type2-driver on z/OS DB version 7, we have a problem getting the connection to the database. The small program we use looks like this: ...
6
by: Chas Emerick | last post by:
This may seem like it's coming out of left field for a minute, but bear with me. There is no doubt that Ruby's success is a concern for anyone who sees it as diminishing Python's status. ...
29
by: walterbyrd | last post by:
Some think it will. Up untill now, Java has never been standard across different versions of Linux and Unix. Some think that is one reason that some developers have avoided Java in favor of...
34
by: Anthony Irwin | last post by:
Hi All, I am currently trying to decide between using python or java and have a few quick questions about python that you may be able to help with. #1 Does python have something like javas...
0
by: nadeemabdulhamid | last post by:
Hello, I'm trying to write some Java code that will launch a python interpreter shell and pipe input/output back and forth from the interpreter's i/o streams and the Java program. The code posted...
18
by: Jens | last post by:
I'm starting a project in data mining, and I'm considering Python and Java as possible platforms. I'm conserned by performance. Most benchmarks report that Java is about 10-15 times faster than...
5
by: hussainsaiger | last post by:
I am trying to convert a python module (that contains the use of NLTK.Corpus) by jythonc. It is not able to include nltk dependencies within the java class it creates. So when i use this class in...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.