Compiling Your Code

InfoInfo
Search:    

Compiling Your Code

WARNING: Make sure you don't have a regular jython installation anywhere near your path before you do this. This is the #1 most frequent problem

Take a look at the dockexample2applet.py script. The one important thing to note is that you will not be able to use many of the shortcuts (compare the script to dockexample2.py). This means that you will need to use commands like g.gemLayout() instead of gemLayout(). If you are unsure what the “real” command is take a look at Main.py which defines all the shortcuts.

We have also noticed that objects need to be declared using their full package name (so javax.swing.JSlider instead of just JSlider). We may be able to fix this in the future, but you should check your scripts here.

Once you have this and set your environment variables correctly (in particular you’ll want the same classpath that is set in guess.bat) you should be able to run the following command (in windows):

jythonc -j foo.jar -a -c -p guess --deep scripts\dockexample2applet.py

This will compile the dockexample2 toolbar into a java class and then package it inside the foo.jar file. The command will also include all the necessary python code in the jar file. The –p option tells jython to put the class in the “guess” package. This is important because there is some classloader code that tests to see if the toolbar is in the guess package before loading it. Once you have foo.jar you should be able to load test2.html which makes reference to the new toolbar (take a look at the bottom of the file where the TOOLBAR variable is defined).

If jython complains about not being able to find the compiler or something about the registry variable you’ll want to use the command:

jythonc -j foo.jar -a -c -p guess –C c:\jdk\bin\javac.exe --deep scripts\dockexample2applet.py

replacing the c:\jdk\... with the location of your javac.

This is a Wiki Spot wiki. Wiki Spot is a non-profit organization that helps communities collaborate via wikis.