【问题标题】:JAVA3D- First program- error [duplicate]JAVA3D-第一个程序-错误[重复]
【发布时间】:2012-07-20 19:59:36
【问题描述】:

可能重复:
problems with java3D lib configuration

我想在 Ubuntu 上使用 JAVA 制作一个 3d 游戏,因此我从http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-client-419417.html#java3d-1.5.1-oth-JPR 下载了j3d-1_5_2-linux-i586.zip,并解压了它。在Eclipse中,我在eclipse的../j3d-1_5_2-linux-i586/lib/ext/中添加了3个jar,然后写了这段代码

import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;

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();
    }

}

收到这些错误

Description Resource    Path    Location    Type
Access restriction: The constructor SimpleUniverse() is not accessible due to restriction on required library /home/emil/Downloads/j3d-1_5_2-linux-i586/lib/ext/j3dutils.jar    Hello3d.java    /Checker3D/src  line 7  Java Problem

    Description Resource    Path    Location    Type
Access restriction: The constructor BranchGroup() is not accessible due to restriction on required library /home/emil/Downloads/j3d-1_5_2-linux-i586/lib/ext/j3dcore.jar    Hello3d.java    /Checker3D/src  line 8  Java Problem

Description Resource    Path    Location    Type
Access restriction: The constructor ColorCube(double) is not accessible due to restriction on required library /home/emil/Downloads/j3d-1_5_2-linux-i586/lib/ext/j3dutils.jar   Hello3d.java    /Checker3D/src  line 9  Java Problem

还有更多类似的 我将“Deprecated and restricted API”下的“Forbidden reference (access rules)”从“**Error**”设置为“**Warning**”。

关于建设 我得到了

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:7)
    at Hello3d.main(Hello3d.java:15)

Run--->Run Configuration ---> JAVA applications--->(x=)arguments--->VM argiments,我添加了

-Djava.library.path=$LD_LIBRARY_PATH:/home/emil/Downloads/j3d-1_5_2-linux-i586/lib/i386/

我收到了这个错误

Exception in thread "main" java.lang.NoClassDefFoundError: Checker
Caused by: java.lang.ClassNotFoundException: Checker
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Checker. Program will exit.

【问题讨论】:

    标签: java-3d


    【解决方案1】:

    这是你的答案,干杯!

    Windows -> 首选项 -> Java -> 构建路径 -> 用户库 1. 新建:J3DAll,2. 添加 JAR .. 在 ..\jre6\lib\ext\j3dcore.jar、j3dutils.jar 中选择所有三个, vecmath.jar

    Project -> Properties -> Java Build Path -> Libraries Add Library .. -> User Library -> 接下来选择 J3DAll Finish Project -> Properties -> Java Build Path -> Order and Export Top J3DAll

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-29
      • 2020-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-26
      相关资源
      最近更新 更多