java3D lib 配置问题
我在配置 java3D 以与我的 IDE 环境一起工作时遇到了一些麻烦...
我已经下载了 j3d-1_5_2-linux-i586.zip,并解压了 j3dcore.jar、j3dutils.jar、vecmath.jar、libj3dcore-ogl.so、libj3dcore -ogl-cg.so 并将它们全部添加为我的项目文件夹中的“参考库”。这消除了我收到的任何编译警告,但是当我编译并运行应用程序时,我收到以下异常!
Exception in thread "main" java.lang.UnsatisfiedLinkError: no j3dcore-ogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:299)
at Hello3d.<init>(Hello3d.java:10)
at Hello3d.main(Hello3d.java:18)
这里也可以快速浏览一下源代码。注意:一旦将导入库路径添加为引用库,Eclipse 就会自动使用 Ctrl+Shift+O 拉入导入库路径。
import javax.media.j3d.BranchGroup;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;
public class Hello3d {
public Hello3d(){
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
group.addChild(new ColorCube(0.3));
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main(String[] args){
new Hello3d();
}
}
我不确定我对“j3dcore-ogl”的意思是什么,但我陷入了这一点。如何在系统环境或IDE项目中安装java3D?请帮忙。
IDE:Eclipse SDK 3.5.2
JVM:java-6-sun-1.6.0.22
操作系统:Ubuntu 10.04 LTS
ive ran into some trouble configuring java3D to work with my IDE environment...
I have downloaded j3d-1_5_2-linux-i586.zip, and unpacked j3dcore.jar, j3dutils.jar, vecmath.jar, libj3dcore-ogl.so, libj3dcore-ogl-cg.so and added them all as 'Referenced Libraries' within my project folder. this gets rid of any compilation warnings I was getting but when I compile and run the application I get the following exception!
Exception in thread "main" java.lang.UnsatisfiedLinkError: no j3dcore-ogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:299)
at Hello3d.<init>(Hello3d.java:10)
at Hello3d.main(Hello3d.java:18)
here is a quick look at the source code as well. NOTE: Eclipse pulled in the import libraries paths automatically with Ctrl+Shift+O once they were added as Referenced Libraries.
import javax.media.j3d.BranchGroup;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;
public class Hello3d {
public Hello3d(){
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
group.addChild(new ColorCube(0.3));
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main(String[] args){
new Hello3d();
}
}
im not sure what im meant to do with 'j3dcore-ogl' but im stuck at this point. how do you install java3D within the system environment or the IDE project? please help.
IDE: Eclipse SDK 3.5.2
JVM: java-6-sun-1.6.0.22
OS: Ubuntu 10.04 LTS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我知道这个问题已经有几年了,但这里的答案不足以让我解决问题。他们只提供了部分帮助。 http://www.filsa.net/2008/07/17/eclipse-java3d -and-javalibrarypath/ 也有一点帮助,但仍然不够。因此,我觉得有必要编写一份完整的清单,以便 Java3D 在 Eclipse 中工作。
几个月前,我已经遇到了同样的问题,我以某种方式解决了它,但没有真正理解我做了什么。今天我想在另一台计算机上设置我的环境,你猜怎么着,我又遇到了同样的问题。我忘记了我必须做什么......但这一次,我更系统地解决了这个问题,现在我明白了每一步。
解决方案 - 每一步都详细
1) 如果您要导入其他人的项目,请确保在 Eclipse 中安装并选择了正确的 JDK 和 JRE。我的 Eclipse 选择了最新的 JRE 7。这是我安装的唯一一个。但是我从事的项目需要 JDK 6 和 JRE 6。如果您需要有多个 java 版本
2) 在 Eclipse 中,您必须执行以下步骤来选择正确的 JDK 和 JRE。
3) 正确设置 Java 环境后,请确保您的计算机上安装了 Java3D。你不能做任何错事。
4) 在 Java3D 安装目录中,找到文件
如果您正确设置了环境,这些文件位于何处并不重要,我将对此进行解释。因此,如果您愿意,您可以将这些文件复制到您的项目目录中,以便将您需要的所有内容集中在一处。
5) 找到这些文件后,请确保
在 Windows 下,要设置 PATH 变量,请在控制面板中打开“系统设置”,然后选择“高级系统设置”。在底部,您将找到“环境变量”按钮。在系统变量列表中,您将找到变量“Path”。确保 j3dcore-ogl 目录包含在路径列表中。
6) 现在是拯救我今天的部分了。
vecmath.jar中列出的每个 Java3D 库
您需要指定本机库位置。本机库是j3dcore-ogl.dll,因此编辑本机库位置以指向包含j3dcore-ogl.dll 的目录。
我相信,这些都是在 Eclipse 中设置 Java3D 必须完成的步骤,因为我今天在一台新计算机上设置了所有内容。现在我希望这些说明能够拯救其他一些可怜的 Java 初学者、学生或程序员的日子:-)
I know this question is now a few years old, but the answers here were not enough for me to solve the problem. They only helped partially. http://www.filsa.net/2008/07/17/eclipse-java3d-and-javalibrarypath/ was also a bit helpful, but it was still not enough. Therefore I felt obliged to write a complete checklist to have Java3D work in Eclipse.
A few months ago, I already had the same problem and I somehow solved it without really understanding what I did. Today I wanted to set up my environment on a different computer and guess what, I had the same problem again. And I forgot what I had to do... This time however, I solved the problem more systematically and now I understand every step.
The Solution - every step in detail
1) If you are importing someone else's project, make sure to have the correct JDK and JRE installed and selected in Eclipse. My Eclipse had selected the latest JRE 7. The only one I had installed. But the Project that I work on requires JDK 6 and JRE 6. I recommend the following structure on your file system if you need to have multiple java versions
2) In Eclipse, you will have to do the following steps to select the correct JDK and JRE.
3) Having your Java environment set up correctly, make sure that Java3D is installed on your machine. You can't do anything wrong with this.
4) In your Java3D installation directory, locate the files
It doesn't matter where these files are located if you setup your environment correctly, which I will explain. So if you want, you can copy these files into your project directory to have everything you need in one place.
5) Having located these files, make sure that
Under Windows, to set the PATH variable, you open the System Settings in your Control Panel and select Advanced System Settings. On the bottom you will find the button "Environment Variables". In the System Variables list you will find the variable "Path". Make sure the directory of j3dcore-ogl is included in the list of paths.
6) Now comes the part that saved my day today.
For each of the Java3D Libraries listed in the Java Build Path
you need to specify Native Library Location. The Native library is the j3dcore-ogl.dll, so edit the native library location to point to the directory containing j3dcore-ogl.dll.
I believe, that these are all steps that must be done to setup Java3D in eclipse, because I set up everything on a fresh computer today. Now I hope that these instructions will save some other poor Java-beginners', students' or programmers' day :-)
Java 抱怨是因为它无法在 Java3D 附带的系统路径上找到本机库(*.so 文件)。具体如何解决这个问题取决于您。您可以执行以下任一操作:
1) 确保您的系统路径包含 Java3D 提供的 *.so 文件
2) 设置 LD_LIBRARY_PATH 环境变量:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/"path-to-java3d-libraries"/
3) 执行java时设置java.library.path:
java -Djava.library.path=$LD_LIBRARY_PATH:/usr/lib/"path-to-java3d-libraries"/
要确保设置正确,请将以下内容添加到 Java 代码中,并确保报告的路径包含其上的共享库
Java is complaining because it cannot find the native libraries (the *.so files) on your system path that Java3D comes with. Exactly how you fix this is up to you. You can do anyone one of the following:
1) Make sure that your system path includes the *.so files provided with Java3D
2) Setup your LD_LIBRARY_PATH environment variable:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/"path-to-java3d-libraries"/
3) Set the java.library.path when executing java:
java -Djava.library.path=$LD_LIBRARY_PATH:/usr/lib/"path-to-java3d-libraries"/
To be sure you have things set correctly, add the following to your Java code and make sure the path reported contains the shared libraries on it
我知道这是一个非常老的问题,但一些开发人员仍在安装过时的 Java 3D 版本,无论有没有 IDE,该版本都很难使用。请使用 Java 3D 1.6.0 并按照此处提供的详细说明(英语和法语)进行操作。
I know it's a very old question but some developers are still installing an obsolete version of Java 3D which is harder to use with or without an IDE. Please rather use Java 3D 1.6.0 and follow my detailed instructions (in English and in French) available here.
作为给定答案的附录,帮助我设置 java 3d 的是:
将所有 .dll 文件从“C:\Program Files\Java\Java3D\1.5.X\bin\”复制并粘贴到“C:\Program Files\Java\jre6\bin\”。
因此,将Java3D形成为我实际的jre6(从bin到bin)。
之前我还将类路径/(您也可以设置路径)设置为
3dcore.jar、j3dutils.jar、vecmath.jar、j3dcore-ogl.dll
但还是没用。
复制过去的 j3dcore-ogl.dll (如上所述)并将类路径保留为 3dcore.jar、j3dutils.jar、vecmath.jar (在“C:\Program Files\Java\Java3D\1.5.X\ext\”中)后,它起作用了美好的。
我在这里找到了帮助:http://www.xinapse.com/Manual/install_windows.html
看点2。
最好的问候
As an addendum to given answers, what helped me set java 3d was:
Copy and paste all the .dll files from "C:\Program Files\Java\Java3D\1.5.X\bin\" to "C:\Program Files\Java\jre6\bin\".
So form Java3D to my actual jre6(from bin to bin).
Previously I also set the classpath/(you can also set path) to
3dcore.jar, j3dutils.jar, vecmath.jar, j3dcore-ogl.dll
but still did not work.
After copy past j3dcore-ogl.dll (described above) and left classpath to 3dcore.jar, j3dutils.jar, vecmath.jar (in "C:\Program Files\Java\Java3D\1.5.X\ext\") it worked fine.
I have found help here: http://www.xinapse.com/Manual/install_windows.html
Look at the point 2.
Best regards
项目/属性/java 构建路径/源选项卡/展开并选择本机库位置/导航到 i386 文件夹。
project/properties/java build path/source tab/expand and select native library location / navigate to i386 folder.
(Windows同样问题已解决)
复制:
j3dcore-ogl.
“dll”到此文件夹并尝试!(Windows same problem resolved)
copy:
j3dcore-ogl.
"dll" to this folder and try!对于 netbeans(此处为 12.2),您还必须添加 3 个外部库依赖项(j3dCore.jar、j3dutils.jar、vecmath.jar),但您无法像 Eclipse 项目中提到的那样添加“本机库位置”,因此改为你必须:
-Djava.library.path =“C:\ Local \ Java” \Java3D\1.5.1\bin"
还要在系统路径中添加 j3dcore-ogl.dll 库的正确路径,在我的例子中又是 ' C:\Local\Java\Java3D\1.5.1\bin '(根据您的情况进行调整)
希望它对 Netbeans 用户有所帮助。
另外,我安装的 j3d 版本很旧,但我需要它来测试旧项目。
For netbeans (12.2 here), you have also to add the 3 external libraries dependency (j3dCore.jar, j3dutils.jar, vecmath.jar), but you cannot do the "native library location" addition as mentionned for Eclipse project, so instead you have to :
-Djava.library.path="C:\Local\Java\Java3D\1.5.1\bin"
Also add in your system path the correct path to the j3dcore-ogl.dll library, in my case again ' C:\Local\Java\Java3D\1.5.1\bin ' (adjust to yours)
Hope it helps Netbeans users.
Also, the j3d version i installed is old but i needed it to test old project.
只要尝试这段代码,它对我有帮助:
Just try to this code, it's help me:
我也有同样的问题。解决了设置本机路径的问题:
属性 - java 构建路径 - 库 - java3Dlib - 本机库位置 - 外部文件夹 ----->找到路径:....Java/Java3D/1.5.1/bin 或文件所在路径:j3dcore-ogl.dll
I had the same problem. Solved it setting the Native path:
Properties - java build path - libraties - java3Dlib - Native library location - External folder -----> find the path: ....Java/Java3D/1.5.1/bin or the path where is the file: j3dcore-ogl.dll
已解决 - JonnyO 的答案是正确的。
我在 Linux 上使用 java 8,并从 https://java3d.java.net/binary- 下载builds.html(对于intel 64位系统,采用linux-amd64版本)。
解压下载的文件后,然后解压其中包含的j3d-jre.zip并将jar文件添加到项目中并将libj3dcore-ogl.so添加到jar中,它仍然不起作用。我必须将 libj3dcore-ogl.so 添加到库路径中。 (我很懒,我只是将它复制到/usr/lib,就足够了。)
现在它可以工作了。
PS:请确保事先删除任何其他 j3dcore.jar 和 j3dutils.jar。
SOLVED - JonnyO answer is right.
I am using java 8 on linux, and downloaded from https://java3d.java.net/binary-builds.html (take the linux-amd64 version for an intel 64 bit system).
After unzipping the downloaded file, and then unzipping the contained j3d-jre.zip and adding the jar files to project and the libj3dcore-ogl.so to the jar, it still did not work. I had to add the libj3dcore-ogl.so to the library path. (Lazy as I am, I just copied it to /usr/lib, what is sufficient.)
Now it is working.
PS: Make sure to remove any other j3dcore.jar and j3dutils.jar beforehand.
我遇到了这个确切的问题,我的解决方案(我使用 eclipse)是下载 32 位(i586)(来自 https://java3d.java.net/binary-builds.html)存档并使用这些本机。
I had this exact problem and the solution for me (I use eclipse) was to download the 32-bit (i586) (from https://java3d.java.net/binary-builds.html) archive and use those natives.
我最近遇到了同样的问题,以下是我修复它的方法:
运行“strace java filename”并在顶部附近查找类似“open(”/usr/lib/jvm/java -8-oracle/jre/bin/../lib/amd64/libpthread.so”,它会告诉您系统正在加载哪些二进制文件。
就我而言,重要的是 amd64。
返回 java3d 下载页面并下载(在本例中)amd64 版本的二进制文件并覆盖 lib/ext 中的 .so 文件(vecmath、j3dcore 和 j3dutils)。
再次测试您的 java3d 程序,它应该可以正常工作。
I recently ran into this same problem, here's how I fixed it:
Run 'strace java filename' and look near the top for lines like "open("/usr/lib/jvm/java-8-oracle/jre/bin/../lib/amd64/libpthread.so" which will tell you what binaries your system is loading.
In my case, it's amd64 that matters.
Go back to the java3d download page and download the binaries for (in this case) amd64 verson and install that. Overwrite the .so files in lib/ext (vecmath, j3dcore, and j3dutils).
Test your java3d program again, it should be working.
我遇到了这个问题。
下载 java3d 插件并安装就足够了。
在您的搜索引擎(如 Google)中搜索“java3d 插件”
并下载并安装它。
I had this problem.
it is enough you download java3d plugin and install it.
in your search engine like Google search "java3d plugin"
and download so install it.