invoking a jzy3d app from matlab ...

102 views
Skip to first unread message

Belinda Marchand

unread,
Jun 27, 2014, 10:36:19 PM6/27/14
to jz...@googlegroups.com
Normally, when I invoke a java app from the command prompt I do something like this:

java -cp %PATH_TO_JAR_FILE%\myJAR.jar my.package.myclass

In my current configuration I have the jzy3d DLL dependencies on my windows path. I'm running windows 7 64-bit. Now, I have a Java graphical application that has an embedded jzy3d canvas within it. I can use the above command to start the application from the windows prompt, or I can start it from matlab using a call like this:

system('java -cp %PATH_TO_JAR_FILE% my.package.myclass')

Normally, to run any of the java apps directly from matlab the first thing I do is add the JAR file to the Matlab dynamic path. Then, all I have to do to run an application is something like this from the matlab prompt:

my.package.myclass

Now, in this case, I try to define the object calling its default empty constructor by typing:

o = my.package.myclass;


The problem is that this only works for console and graphical apps that do NOT have an embedded jzy3d canvas or dependency. If I type the above assignment statement at the matlab prompt, after the JAR has been loaded into the dynamic classpath, I get this error:

Catched FileNotFoundException: C:\mypath\myJAR.jar (The system cannot find the file specified), while TempJarCache.bootstrapNativeLib() of
jar
:file:/C:/mypath/myJAR-natives-windows-amd64.jar!/ (file:/C:/mypath/ + myJAR-natives-windows-amd64.jar)
Java exception occurred:
java
.lang.UnsatisfiedLinkError: jogamp.common.jvm.JVMUtil.initialize(Ljava/nio/ByteBuffer;)Z
 at jogamp
.common.jvm.JVMUtil.initialize(Native Method)
 at jogamp
.common.jvm.JVMUtil.<clinit>(JVMUtil.java:58)
 at com
.jogamp.common.os.Platform$1.run(Platform.java:189)
 at com
.jogamp.common.os.Platform$1.run(Platform.java:183)
 at java
.security.AccessController.doPrivileged(Native Method)
 at com
.jogamp.common.os.Platform.<clinit>(Platform.java:183)
 at javax
.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
 at org
.jzy3d.chart.Settings.<init>(Settings.java:19)
 at org
.jzy3d.chart.Settings.getInstance(Settings.java:48)
 at
my.package.myclass.initializePlotWindow(myclass.java:416)
 at
my.package.myclass.<init>(myclass.java:153)



Now, the file it's complaining about doesn't exist cause the JAR file I loaded is called myJAR.jar. So, just to see if it works, I create a duplicate copy and rename it to myJAR-natives-windows-amd64.jar, then restart matlab and reload myJAR.jar into the dynamic java path. Then I reattempt the assignment statement and get this error instead: (see below). Now it's not complaining about the file anymore, which is a good sign, but it complains about "No default device available". Is there some sort of configuration required to get a jzy3d based JAVA app to run from MATLAB? Some additional JARs I need to load? I figured since I purposefully built the JAR file so that ALL JAR dependencies are embedded within, and the DLL dependencies are all on the windows path, it should have access to everything it needs. That certainly works when running the app from the DOS prompt, eclipse, or through any other windows based APP. The problem is specific to MATLAB as far as I can tell. Just wondering if anyone has seen anything like this before.


Java exception occurred:
javax
.media.opengl.GLException: No default device available
        at javax
.media.opengl.GLProfile.getProfileMap(GLProfile.java:1860)
        at javax
.media.opengl.GLProfile.isAvailable(GLProfile.java:223)
        at javax
.media.opengl.GLProfile.isAvailable(GLProfile.java:237)
        at org
.jzy3d.chart.Settings.<init>(Settings.java:19)
        at org
.jzy3d.chart.Settings.getInstance(Settings.java:48)
        at
my.package.myclass.initializePlotWindow(myclass.java:416)
        at
my.package.myclass.<init>(myclass.java:153)


Belinda Marchand

unread,
Jun 27, 2014, 10:46:56 PM6/27/14
to jz...@googlegroups.com
I should note that MATLAB has its own copy of gluegen-rt.jar and jogl.jar in its path, so it may be some sort of conflict between what jzy3d uses and what matlab uses, but I'm not sure. Like I said, all JAR dependencies are embedded within the myJAR.jar file itself. Perhaps this is just a limitation and no Java app that has an embedded jzy3d canvas will ever work from matlab as a result, but I'm hoping someone has come across a viable solution to this. It would be better to have the results of the GUI execution directly available form MATLAB rather than runnign the app externally, saving the results to a file, and then loading to MATLAB.

                   
 D:\Program Files\MATLAB\R2012b\java\jarext\jogl.jar                                            
 D
:\Program Files\MATLAB\R2012b\java\jarext\gluegen-rt.jar                    

Belinda Marchand

unread,
Jun 27, 2014, 11:13:08 PM6/27/14
to jz...@googlegroups.com
The related dll's live under the MATLAB\R2012b\bin\win64 folder, gluegen-rt.dll and jogl.dll

Belinda Marchand

unread,
Jun 27, 2014, 11:32:40 PM6/27/14
to jz...@googlegroups.com
I found a related post on the mathworks website:


Apparently, part of the solution may be replacing the jogl 1.1.1 that ships with matlab with JOGL2. 
Reply all
Reply to author
Forward
0 new messages