473,414 Members | 1,775 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,414 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 2136
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.