开发者

Is it impossible to embed Java3D in a way that I don't need to install it?

开发者 https://www.devze.com 2023-01-01 17:17 出处:网络
I\'m running a big application and a small part of it includes Java 3D, the problem is many users need to use the code, but it isn\'t practical for everyone to install Java 3D just to run the applicat

I'm running a big application and a small part of it includes Java 3D, the problem is many users need to use the code, but it isn't practical for everyone to install Java 3D just to run the application if they aren't even going to use that section of the application.

Is it possible through compiling an extra jar, or changing some paths, to include Java 3D in a project without开发者_JAVA百科 installing it on a system? Or perhaps to manually include any dlls?


The demos at java3d prove that it is possible. You only need to include the required jar files to your projects distribution.


Yes, it is possible. You will need to pull the required jars and native libraries from the java3d site. I pulled them from the java3d demos, but that requires digging through the xml launch descriptor files.

The place you'll run into the most trouble is when linking to the .so / .dll files. This is typically specified on the classpath before your app starts, but since you don't know what platform you're using until your app starts, it's a catch22.

There are two possible solutions: 1. Bootstrap your program with a simple class that detects the platform and sets up a new jvm (with the proper libraries specified) for the real application. 2. Dynamically load the libraries (I've never actually used this method for native implementations, but I see no reason why it wouldn't be possible).

Unfortunately, neither method is terribly straight forward.


I've done this with no problems (and many users tested that it works, Windows OS) by simply adding the jars to the classpath and dropping the appropriate dlls into the "working" directory where the .bat file running Java started. One catch is I had to have two bat files - one 32 bit and one 64 bit. Each bat file copy/renames the appropriate dll to j3dcore-ogl.dll, since depending on which version of Java (32/64 bit) you're running, a different jar is needed.

Example .bat file:

del j3dcore-ogl.dll copy j3dcore-ogl-64.dll j3dcore-ogl.dll java -Xmx2048m -classpath ./YourJar.jar;./lib/tinylaf.jar;./lib/j3dcore.jar;./lib/j3dutils.jar;./lib/vecmath.jar your.package.MainClass @pause

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号