2012-05-23 4 views
0

J'essaie de porter mon application LWJGL vers une applet pour être jouée en ligne, mais je n'arrive pas à comprendre comment donner le bon chemin au indigènes.LWJGL Applet java.lang.UnsatisfiedLinkError: non lwjgl dans java.library.path

Voici le code .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() 
    { 

    } 
} 

Heres le code 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> 

Heres la sortie d'erreur:

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) 
+0

Utilisez-vous le [LWJGL AppletLoader] (http://www.lwjgl.org/wiki/index.php?title=Deploying_with_the_LWJGL_Applet_Loader_-_Introduction)? – Perception

+0

Non, je n'étais pas. Maintenant je suis et ça marche, un peu. J'ai de la difficulté à récupérer mes ressources. "java.lang.RuntimeException: Ressource non trouvée: res/images/font/pixel.ttf \t at org.newdawn.slick.util.ResourceLoader.getResourceAsStream (ResourceLoader.java:69) ..." Des idées? –

+0

J'ai fait mon commentaire dans une réponse ci-dessous, n'hésitez pas à accepter car il semble avoir résolu votre problème (initial). Pour le problème de chargement des ressources, SVP postez une question distincte et incluez-y le code de chargement de votre ressource et la structure du projet où ils sont stockés. – Perception

Répondre

0

Il y a une différence significative entre la façon dont Les bibliothèques natives sont localisées par le runtime Java lors de l'exécution dans une application de bureau par rapport à une applet. Comme une applet est regroupée et transmise pour être exécutée dans le navigateur des clients, vous devez inclure la plupart des dépendances dont elle aura besoin, en particulier pour les bibliothèques natives qu'elle référence. Heureusement, LWJGL fournit une classe d'assistance pour la gestion des applications déployées en tant qu'applications.

En savoir plus sur le LWJGL AppletLoader et comment l'intégrer dans votre application.

0

La tête de votre balise applet est faux, est devrait être comme suit

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

De plus, le idk.jar doit être ajouté au paramètre al_jars. Le reste semble correct.