I am glad to hear that you have worked things out. I know that sometimes
development can be frustrating but when it all works, it's a wonderful
thing. Perseverance pays off. :)
From: Ivan Horvath [mailto:pillesoft@...
Sent: Monday, September 17, 2007 1:51 AM
To: Moore, Greg
Subject: Re: [Jython-users] Distributing Jython Scripts
thank you for this long answer, i've read learningjython document
also. i was really helpful.
my application is an interface between a primavera api, and our visual
foxpro based application.
this interface is rather complication because i need to work with a
java-com bridge, and because PV api is written in java, and i need
also some simple gui, i've chosen jython to develop.
my only problems was to distribute the application. because of the
complexity i used to create a jar file (jython 2.1), and used
now with jython 2.2 jar compilation is not possible anymore, and
sending source files to client is not the best solution. we've spent
some days because of installing 3rd party modules, and setting up
that's why i've decided to try your solution with standalone jython jar
i've extracted/copied all necessary 3rd party jar files into
standalonejython.jar file, and copied my source files into lib\schif.
of course i have __init__.py also :-)
finally i find out also the solution to my problem:
my problem was that i cannot start my application. i thought that
Test.py (in your example) is also a part of the standalonejython.jar,
but it is not. it is a separate file, which can import packages from
the jar file.
so thank you Greg for your patient.
On 9/15/07, Moore, Greg <Greg_W_Moore@...> wrote:
> Hi Ivan,
> Ok well one step at a time... My apologies that this turned out to be
> long. I've hacked apart your email and responded to your questions
> I'd strongly recommend that you read
> http://wiki.python.org/jython/LearningJython (Dave did a really
> excellent job on it) and maybe a book on Java. Although Jython is
> 'Python in Java' and you can do quite a lot with out knowing any Java,
> doing the things you want to do, does require some knowledge of basic
> Java concepts and more advanced Jython concepts.
> > i copied my modules in a
> > subfolder of the lib (not to mix with the jython packages)
> If you copied the files to a subfolder e.g. \lib\your_Folder
> that changes thing completely. In terms of how the modules are now
> referenced, further if you didn't put a __init__py in the directory
> Jython won't 'see' them. See section 7.2 of
> Your script would have to be changed from:
> Import myScript
> To: Import your_Folder.myscript
> Or: from your_Folder.myscript import *
> > copy class files to org, or com folder: i don't know what class
> > do you mean?
> In the Java programming language, source files (.java files) are
> compiled into class files which have a .class extension.
> For more then you ever wanted to know about class files see
> Class files are packaged in Jar files. Just about any Java project has
> at least one jar file. See http://en.wikipedia.org/wiki/Jar_file
> If the all you have is *.py files and you are not using any Java
> within your script. That means no lines that begin from java or from
> javax or import java or import javax. Then maybe the previous 2
> paragraphs are unnecessary and you may not need to copy any class
> Please don't confuse class files (*.class) with jython or
> Java/Jython/Python classes. With Java specifically, a file fubar.class
> is a compiled version of the class 'fubar'. Take a look at section 10
> > i tried to start with this command:
> > java -jar jythonStandalone.jar PmsApi.py or any other file, i
> > the following error:
> > Traceback (innermost last):
> > (no code object) at line 0
> > IOError: File not found - org.PmsApi (The system cannot find the
> > specified)
> Is the name of the file PmsApi.py or something else?
> If it is, where is 'org.PmsApi' coming from And what is it?
> > as you can see i'm not really a java expert, can you give an example
> > of your application, please?
> I am not anywhere near being a Java expert. There are many, maybe
> of the the developers on this mailing list the at are wiser then I am
> Java related matters. I'm just a Software QA guy that has tested a lot
> of Java stuff.
> > what is the stru of your jar file?
> I'll do the best I can in but since diagrams get messed up with
> reformatting, here is the verbose version. First understand that I'm
> using code provided by several different open source projects and the
> resulting structure of the stand alone jar file that I end up with may
> look very different from what you actually need. That being said;
> are a few important directories off the root: org, lib and com. I put
> the directory structures from the different open source projects went
> into the org directory. The \org directory already contains a
> called Python and I added jaxen, apache, and dom4j. My support Jython
> code (*.py files) went into \lib and the rest remained untouched.
> > what is the command to start the application?
> Because I'm still developing parts of it I haven't added everything to
> the jar file. So the command I use is:
> java -jar jythonStandalone.jar Test.py
> Ivan, I hope this helps.
> This message and any attachments are intended only for the use of the
addressee and may contain information that is privileged and
confidential. If the reader of the message is not the intended recipient
or an authorized representative of the intended recipient, you are
hereby notified that any dissemination of this communication is strictly
prohibited. If you have received this communication in error, please
notify us immediately by e-mail and delete the message and any
attachments from your system.
This message and any attachments are intended only for the use of the add=
ressee and may contain information that is privileged and confidential. I=
f the reader of the message is not the intended recipient or an authorize=
d representative of the intended recipient, you are hereby notified that =
any dissemination of this communication is strictly prohibited. If you ha=
ve received this communication in error, please notify us immediately by =
e-mail and delete the message and any attachments from your system.