473,724 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

jpype package, could be path problem

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:
python
>>import jpype
everything worked correctly but when i wrote a short script:
"
from jpype import *

jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
java.lang.Syste m.out.println(" hello world")
shutdownJVM()
"
and tried to run it this's got:

"
Traceback (most recent call last):
File "/home/kelemen/workspace/JPype/src/helloAgent.py", line 3, in ?

jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
NameError: name 'jpype' is not defined
"

What would be the reason?

thanks in advanced
Viktor

Sep 20 '06 #1
3 4198

kelemen.viktor wrote:
everything worked correctly but when i wrote a short script:
"
from jpype import *

jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
java.lang.Syste m.out.println(" hello world")
shutdownJVM()
"
and tried to run it this's got:

"
Traceback (most recent call last):
File "/home/kelemen/workspace/JPype/src/helloAgent.py", line 3, in ?

jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
NameError: name 'jpype' is not defined
"

What would be the reason?
Consider this:

# bad style (potential name clash)
from jpype import *
startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

# that's better
import jpype
jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

# for long names of modules
import jpype as jp
jp.startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

And see this:
http://docs.python.org/tut/node8.html

HTH,
Rob

Sep 20 '06 #2
Hi

thanks for your suggestions

ive modified the sample code

"
import jpype
from jpype import *

jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
java.lang.Syste m.out.println(" hello world")
shutdownJVM()
"

and its working. It seems to be quite strange.
What would be the difference between the two import?

Viktor
Rob Wolfe wrote:
Consider this:

# bad style (potential name clash)
from jpype import *
startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

# that's better
import jpype
jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

# for long names of modules
import jpype as jp
jp.startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

And see this:
http://docs.python.org/tut/node8.html

HTH,
Rob
Sep 20 '06 #3

kelemen.viktor wrote:
Hi

thanks for your suggestions

ive modified the sample code
You've modified it incorrect.
"
import jpype
from jpype import *
You should use "import jpype" OR "from jpype import *" (not
recommended)
but NOT BOTH.
jpype.startJVM( '/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
java.lang.Syste m.out.println(" hello world")
shutdownJVM()
"

and its working. It seems to be quite strange.
What would be the difference between the two import?
1. "import jpype"

This does not enter the name of the function startJVM defined in jpype
directly in the current symbol table; it only enters the module name
jpype there.
Using the module name you can access the function like that:

jpype.startJVM( )

2. "from jpype import"

This enters the name of the function startJVM in the currrent symbol
table,
so you can access the function just like that:

startJVM()

And have you read this: http://docs.python.org/tut/node8.html ?

HTH,
Rob

Sep 20 '06 #4

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

Similar topics

3
2296
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...
1
5109
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...
6
4824
by: unlikeablePorpoise | last post by:
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);
1
3192
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...
0
8868
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8741
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
9243
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9160
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
8063
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
6689
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
5996
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
4771
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2613
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.