Java 3D Hello World - Jar 冻结 [英] Java 3D Hello World - Jar freeze

查看:30
本文介绍了Java 3D Hello World - Jar 冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注本教程 构建我的第一个 Java 3D 应用程序.我在我的项目中包含了 java3D 库 和我的 DllLoader 提取(从类路径到 jar 位置)并加载 j3dcore-ogl.dll 的类:

I am following this tutorial to build my first Java 3D application. I included in my project the java3D libraries and my DllLoader class that extracts (from the classpath to the jar's location) and loads the j3dcore-ogl.dll:

public class DllLoader {

    private DllLoader() {
    }

    public static void extractAndLoad(String dll) throws IOException {
        int aux = dll.lastIndexOf('/');
        if (aux == -1) {
            aux = dll.lastIndexOf('\');
        }
        File dllCopy = new File((aux == -1) ? dll : dll.substring(aux + 1));
        try {
            System.load(dllCopy.getAbsolutePath());
        } catch (UnsatisfiedLinkError e1) {
            try {
                DllLoader.copyFile(DllLoader.class.getResourceAsStream(dll), dllCopy);
                System.load(dllCopy.getAbsolutePath());
            } catch (IOException e2) {
            }
        }
    }

    private static void copyFile(InputStream pIn, File pOut) throws IOException {
        if (!pOut.exists()) {
            pOut.createNewFile();
        }
        DataInputStream dis = new DataInputStream(pIn);
        FileOutputStream fos = new FileOutputStream(pOut);
        byte[] bytes = new byte[1024];
        int len;
        while ((len = dis.read(bytes)) > 0) {
            fos.write(bytes, 0, len);
        }
        dis.close();
        fos.close();
    }
}

如果我从 Netbeans 运行项目,或者如果我从命令行使用 java -jar Hello3DWorld.jar" 打开 jar,一切正常.

Everything works fine if I run the project from Netbeans, or if I open the jar from the command line with java -jar Hello3DWorld.jar".

我的问题是:如果我通过简单的双击运行 jar,什么都不会发生.dll 出现在 jar 附近,但框架从未出现.

My problem is this: if I run the jar with a simple double click, nothing happens. The dll appears near the jar, but the frame never appears.

在我的代码中放入一些 JOptionPane.showMessageDialog() 以找出问题所在,我意识到执行不会引发任何异常.它只是在加载 dll 后像循环一样冻结.你能帮我理解为什么它只通过双击罐子就挂了,是什么问题?

Putting some JOptionPane.showMessageDialog() in my code to find out what is going wrong, I realized that the execution throws no exception. It just freezes like in a loop after loading the dll. Can you help me to understand why it hangs only by double clicking the jar and what is the problem?

推荐答案

解决了我的问题 :D
Windows 注册表中存在错误...这是解决方案:
1) 运行 regedit
2)找到HKEY_CLASSES_ROOTjarfileshellopencommand
3) 确保javaw.exe 的路径正确

Solved my problem :D
There were an error in the Windows Registry... this is the solution:
1) run regedit
2) find HKEY_CLASSES_ROOTjarfileshellopencommand
3) make sure the path for javaw.exe is correct

这篇关于Java 3D Hello World - Jar 冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆