473,398 Members | 2,404 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,398 software developers and data experts.

Jython classpath question

Hi all,

Sorry for the newb question, but Googling and FAQing didn't work. Is it
correct that Jython can only access Java classes which are inside JAR
archives in the JYTHON_HOME directory? IT doesn't seem to be documented. I
ask because I want to do groovy prototyping using Jython, and save myself
a lot of coding overhead to try something a little out-of-the-box.

I have a working directory where all my code lives, and because my app is
under rapid development, I would prefer to avoid creating a JAR file every
time I want to do some Python scripting?

What do people suggest I do?

Thanks,
-Tennessee
Jul 18 '05 #1
5 15647
No it is not true. If you can access your class from java, in jar file
or not, (it has to be in the classpath), you can access it from jython.
I've been playing with jython and java a while ago, but I can remember I
had to do a little trying out, before I figured out how to access some
java class. As far as I can remember you can have more java classes in
one *.class file, so it is possible that you have to write:

import classfilename.classname

or similar, but do not blame me if I am wrong here, as far as I can
remember I had to to some trying out in this direction.

There is also a jython mailing list, and two books about jython.
"Tennessee James Leeuwenburg" <t.***********@removme.bom.gov.au> wrote
in message news:pa****************************@removme.bom.go v.au...
Hi all,

Sorry for the newb question, but Googling and FAQing didn't work. Is it correct that Jython can only access Java classes which are inside JAR
archives in the JYTHON_HOME directory? IT doesn't seem to be documented. I ask because I want to do groovy prototyping using Jython, and save myself a lot of coding overhead to try something a little out-of-the-box.

I have a working directory where all my code lives, and because my app is under rapid development, I would prefer to avoid creating a JAR file every time I want to do some Python scripting?

What do people suggest I do?

Thanks,
-Tennessee


Jul 18 '05 #2
On Thursday 17 July 2003 03:29, Tennessee James Leeuwenburg wrote:
Hi all,

Sorry for the newb question, but Googling and FAQing didn't work. Is it
correct that Jython can only access Java classes which are inside JAR
archives in the JYTHON_HOME directory? IT doesn't seem to be documented. I
ask because I want to do groovy prototyping using Jython, and save myself
a lot of coding overhead to try something a little out-of-the-box.


No you can import a java .class file. Just make sure it's on the python path
(sys.path) if both .py and .class files are in the same directory then you
need do nothing... if not then you could add the directory containing the
java class files to python sys.path like so:

import sys

sys.path.append("/path/to/java/class/files")
for more information / alternative suggestions look at :-

http://www.jython.org/docs/registry.html

Regards
Martin

Jul 18 '05 #3
Thanks All.

-Tennessee
Jul 18 '05 #4
I can now import every class except the one which I would most like to
import.

The fully-qualified classname is au.gov.bom.aifs.dv.dv.
I can import anything else from the au.gob.bom tree, and also other things
from the dv tree such as dv.LayerManager. It's just dv.dv that is causing
hassles.

Are there any pitfalls or required naming conventions that I should be
aware of?

Thanks,
-Tennessee
Jul 18 '05 #5
Never mind,

It was barfing on a dependant class that wasn't in the classpath. I was
just misreading the error message.

Thanks guys,
-T
Jul 18 '05 #6

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

Similar topics

4
by: angel | last post by:
A java runtime environment includes jvm and java class (for example classes.zip in sun jre). Of course jython need jvm,but does it need java class. Thanx
7
by: Jan Gregor | last post by:
Hello I found that jython catches exact java exceptions, not their subclasses. Is there some way to get around this limitation (or error) ? My program has class representing database source...
1
by: Nandan | last post by:
hello, can I ask a jython question here? when I use the jython interpreter I have no problem with the statement: from java import lang from javax import swing but when I put this in a...
1
by: scott | last post by:
I installed darwinports and did a "sudo port install jython" ------------------------- scott$ which jython /opt/local/bin/jython ------------------------- Jython works in interactive...
2
by: didier.prophete | last post by:
Ok, so I know this is probably a common jython error, but somehow I can't seem to find an answer to this trivial problem. Ok, I have the following (simple) directory structure: $TOP/...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
1
by: Mark Fink | last post by:
Hi there, I have a source file FailFixture.py in the folder D:\AUT_TEST\workspace\JyFIT\testutil. Now I want to import the file with "import testutil.FailFixture". Unfortunately I could not...
3
by: donkeyboy | last post by:
All, I'm having issues installing Jython on Windows XP. I've looked on the web and this newsgroup but to no avail. Any suggestions? The shell listing is below: NB I've got Cygwin installed,...
5
by: sarup26 | last post by:
Hello .. I would like to know more about Python and Jython? What is the difference between both of them? What is the future for Jython and which are the areas where it is used? Swot
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.