Joined: Jul 26, 2011
Post Count: 62
Status:
Offline
Running Jar File in Mac
Hello,
I have changed the code of Sweethome3d in order to create my own application and I have created an executable jar file. I would like to run it from command line, but for some strange reason it does not.
I use this command in terminal java -jar Blender.jar -Djava.ext.dirs=lib:lib/macosx
but it gives me this mistake
Exception in thread "main" java.lang.SecurityException: sealing violation: package javax.media.j3d is sealed at java.net.URLClassLoader.defineClass(URLClassLoader.java:234) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at com.eteks.sweethome3d.j3d.Component3DManager.setRenderingErrorObserver(Component3DManager.java:104) at com.eteks.sweethome3d.SweetHome3D.addComponent3DRenderingErrorObserver(SweetHome3D.java:491) at com.eteks.sweethome3d.SweetHome3D.init(SweetHome3D.java:383) at com.eteks.sweethome3d.Blender.main(Blender.java:181)
What I have also done is change the MANIFEST.MF in order to have my main class as the main class of the program. Is that wrong?
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Running Jar File in Mac
I use this command in terminal java -jar Blender.jar -Djava.ext.dirs=lib:lib/macosx
In what folder did you run this command? Did you try with absolute paths instead of relative paths "lib" and "lib/macox"?
Even with this: java -jar Blender.jar -vmargs Djava.ext.dirs=lib:lib/macosx
-vmargs isn't a java command option!
Your problem is due to the fact that the JVM doesn't find the Java 3D libs in the extension folders you specified, so it uses the default old ones in the system found in /System/Library/Java/Extensions/. The easiest way to check this is to temporarily remove the j3d*.jar files from this folder, then when you run again your java command, you'll get a NoClassDefFoundError exception about a Java 3D class.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Joined: Jul 26, 2011
Post Count: 62
Status:
Offline
Re: Running Jar File in Mac
I have placed my Blender.jar file in a folder in my desktop. First I open the folder using the cd command, and then I run the jar file. But it seems not to recognize the VM arguments.
You are right about -vmargs, but I was reading a forum and I got confused. I removed temporarily the jar files from this folder as you said, and I got the message.
Now, I tried to run the SweetHome3D-3.3.jar file and it runs perfectly from command line using the command as before.
I will try with absolute paths, and I will tell you the result.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Running Jar File in Mac
I tried to run the SweetHome3D-3.3.jar file and it runs perfectly from command line using the command as before.
It even runs without the -Djava.ext.dirs option. If you want to make your program work as SweetHome3D Jar executable, study how it is built with jarExecutable Ant target.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Joined: Jul 26, 2011
Post Count: 62
Status:
Offline
Re: Running Jar File in Mac
Well, I used the absolute paths in order to show in the Sweethome3d source code right? lib: /Users/dimitramicha/Documents/workspace/SweetHome3D-3.3-src/lib and lib/macosx: /Users/dimitramicha/Documents/workspace/SweetHome3D-3.3-src/lib/macosx which are in the workspace. Which main should I keep? I kept as run configurations the ones that I use to execute the program right? I really am very confused.