English 中文(简体)
LWJGL Applet java.lang. UnsadisfiedLinkError: 在 java.library.path 里没有lwjgl。
原标题:LWJGL Applet java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

我试图将我的LWJGL 应用程序移植到一个小程序上,

以下是.java Applet的代码:

package net.foxycorndog.idk.applet;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Canvas;

import net.foxycorndog.idk.Idk;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;

public class IdkApplet extends Applet
{
    Canvas  drawCanvas;

    Idk     idk;

    /** is the game loop running */
    boolean running = false;

    public void startLWJGL()
    {
        idk.start(drawCanvas);
    }

    /**
     * Tell game loop to stop running, after which the LWJGL Display will be
     * destroyed. The main thread will wait for the Display.destroy().
     */
    private void stopLWJGL()
    {
        running = false;

        try
        {
            idk.getGameThread().join();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }

    public void start()
    {

    }

    public void stop()
    {

    }

    /**
     * Applet Destroy method will remove the canvas, before canvas is destroyed
     * it will notify stopLWJGL() to stop the main game loop and to destroy the
     * Display
     */
    public void destroy()
    {
        super.destroy();
        System.exit(0);
    }

    public void init()
    {
        Idk.init();

        idk = new Idk();

        setLayout(new BorderLayout());
        try
        {
            drawCanvas = new Canvas()
            {
                public final void addNotify()
                {
                    super.addNotify();
                    startLWJGL();
                }

                public final void removeNotify()
                {
                    stopLWJGL();
                    super.removeNotify();
                }
            };

            setSize(640, 512);

            drawCanvas.setSize(getWidth(), getHeight());
            add(drawCanvas);
            drawCanvas.setFocusable(true);
            drawCanvas.requestFocus();
            drawCanvas.setIgnoreRepaint(true);
            setVisible(true);
        }
        catch (Exception e)
        {
            System.err.println(e);
            throw new RuntimeException("Unable to create display");
        }
    }

    protected void initGL()
    {

    }
}

HTML 代码如下:

<html>
    <body>
        <center>
            <div class="rounded">
                <applet code="net.foxycorndog.idk.applet.IdkApplet" name="theapplet" archive="Idk.jar" width="640" height="512" codebase="../applets/Idk">
                    <!-- The following tags are mandatory -->

                    <!-- Name of Applet, will be used as name of directory it is saved in, and will uniquely identify it in cache -->
                    <param name="al_title" value="appletloadertest">

                    <!-- Main Applet Class -->
                    <param name="al_main" value="net.foxycorndog.idk.applet.IdkApplet">

                    <!-- List of Jars to add to classpath -->
                    <param name="al_jars" value="lwjgl_applet.jar.pack.lzma, lwjgl.jar.pack.lzma, lwjgl_util.jar.pack.lzma">

                    <!-- signed windows natives jar in a jar --> 
                    <param name="al_windows" value="windows_natives.jar.lzma">

                    <!-- signed linux natives jar in a jar --> 
                    <param name="al_linux" value="linux_natives.jar.lzma">

                    <!-- signed mac osx natives jar in a jar --> 
                    <param name="al_mac" value="macosx_natives.jar.lzma">

                    <!-- signed solaris natives jar in a jar --> 
                    <param name="al_solaris" value="solaris_natives.jar.lzma">

                    <!-- Tags under here are optional -->

                    <!-- whether to use cache - defaults to true -->
                    <!-- <param name="al_cache" value="true"> -->

                    <!-- Version of Applet (case insensitive String), applet files not redownloaded if same version already in cache -->
                    <!-- <param name="al_version" value="0.1"> -->

                    <!-- Specify the minimum JRE version required by your applet, defaults to "1.5" -->
                    <!-- <param name="al_min_jre" value="1.6"> -->

                    <!-- background color to paint with, defaults to white -->
                    <!-- <param name="boxbgcolor" value="#000000"> -->

                    <!-- foreground color to paint with, defaults to black -->
                    <!-- <param name="boxfgcolor" value="#ffffff"> -->

                    <!-- logo to paint while loading, will be centered, defaults to "appletlogo.gif" -->
                    <!-- <param name="al_logo" value="appletlogo.gif"> -->

                    <!-- progressbar to paint while loading. Will be painted on top of logo, width clipped to percentage done, defaults to "appletprogress.gif" -->
                    <!-- <param name="al_progressbar" value="appletprogress.gif"> -->

                    <!-- whether to run in debug mode -->
                    <!-- <param name="al_debug" value="true"> -->

                    <!-- whether to prepend host to cache path - defaults to true -->
                    <!-- <param name="al_prepend_host" value="true"> -->

                    <param name="separate_jvm" value="true">

                    <p>
                        You re browser must have java enabled to view this content. If you do not have jave installed or the newest version, you can click here to update it to the latest version.
                        <a href="http://java.com/en/download/">Java</a>
                    </p>
                </applet>
            </div>
        </center>
    </body>
</html>

在此错误输出 :

Exception in thread "Thread-14" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
at net.foxycorndog.presto2d.PrestoGL2D.createFrame(PrestoGL2D.java:172)
at net.foxycorndog.idk.Frame.init(Frame.java:163)
at net.foxycorndog.idk.Frame.<init>(Frame.java:75)
at net.foxycorndog.idk.Idk$1$1.<init>(Idk.java:118)
at net.foxycorndog.idk.Idk$1.run(Idk.java:118)
最佳回答

执行桌面应用程序时 Java 运行时间与执行 Applet 程序时本地图书馆的位置差别很大。 因为 Applet 会被捆绑和传输到客户浏览器中运行, 您必须包括它需要的多数依赖关系, 特别是它引用的本地图书馆。 幸运的是, LWJGL 提供了管理应用软件的辅助类, 作为小程序被部署 。

有关"的更多信息:http://www.lwjgl.org/wiki/index.php? title=Depploying_with_the_LWJGL_Applet_Loader____Introduction" rel=“nofollow”>LWJGL AppletLoader 以及如何将它纳入您的申请。

问题回答

您的小程序标记头部错误, 应该有以下标记 :

<applet code="org.lwjgl.util.applet.AppletLoader"
    archive="lwjgl_util_applet.jar" 
    codebase="." 
    width="640" height="512">

另外,idk.jar应该添加到 al_jars 参数中。 其余的看起来是正确的 。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签