Samstag, 21. August 2010

Howto install jhandles in octave 3.2 with ubuntu 10.04


Last evening I joined a discussion on the GNU Octave mailing list about a problem making jhandles work on the current ubuntu. I already succeeded with that on my own machine with octave 3.2.4 and opensuse 11.3 64 bit, so I thought it will work on ubuntu too and gave it a try in a virtual machine.

Ok so I did it with 32 bit ubuntu 10.04 in vmware player (had no chance to do it with 64 bit so please take care that some paths can be slightly different on 64 bit version):

Install the following packages in ubuntu

sudo apt-get install octave3.2 octave3.2-headers
sudo apt-get install openjdk-6-jre openjdk-6-jdk
sudo apt-get install libjogl-java
sudo apt-get install mesa-common-dev

The following symbolic links are a workaround to make the configure scripts of the installer find the packages and there may be better solutions, but at least it works.

cd /usr/lib
sudo cp -s /usr/lib/mesa/libGL.so.1 libGL.so

cd /usr/bin

sudo cp -s /usr/share/java/jogl.jar .
sudo cp -s /usr/share/java/gluegen-rt.jar .

Download the octave java package 1.2.7 from octave forge
Download jhandles 0.3.5 from octave forge.

Extract the jhandles package and navigate to the src folder. Open the configure script with an editor of your choice.
In the lines 4335, 4337, 4341 and 4342 change

octave -qf

to

octave -q

Save the file.

(Delete only the character f make sure you do not change anything else, do not delete the character ` at the end of the lines).
Change into the folder where you downloaded this packages for example

cd ~/Downloads

Run octave as root to install the packages system wide

sudo octave

Then proceed in octave

setenv("JAVA_HOME", "/usr/lib/jvm/java-6-openjdk")

pkg install -verbose java-1.2.7.tar.gz

(you will get some compiler warnings which can safely be ignored)

check that the functions from the java package are really available and work.

help java_new
type java_new
x = java_new ("java.lang.StringBuffer", "Initial string")
x.toString()

None of these commands should give error messages. So at this point you have the java binding s successfully installed.

Let's proceed with jhandles:

pkg install -verbose jhandles-0.3.5

ignore the warnings and exit octave.

Add the following lines to your .octaverc file with an editor of your choice in your home directory (create this file if there is none) before you proceed.

javaaddpath("/usr/share/java/gluegen-rt.jar")
javaaddpath("/usr/share/java/jogl.jar")


Now start octave as normal user

The command pkg list should now show

java *| 1.2.7 | /usr/share/octave/packages/3.2/java-1.2.7
jhandles | 0.3.5 | /usr/share/octave/packages/3.2/jhandles-0.3.5

Test the jhandles functionality with the following code snippet:

pkg load jhandles
sombrero
shading interp


Hopefully it works also for you.