Stuck in the "switching applet" phase

Started by TomSuede, February 09, 2009, 01:59:15

Previous topic - Next topic

TomSuede


     Hi everyone,

  I'm new here, and new to almost everything that is discussed in that forum, so please be gentle and excuse my ignorance ;)

  I'm use to develop in C++, but I decided to try Java, in order to develop applications for web, and actually, I decided Java only to try 3D on the web, that's why i got interested in LWJGL.
  Right now, I have a problem when launching the applet on a navigator : I tried to create an applet with NetBeans, on which I added an AWTGLCanvas (actually, the Gears demo). When I try the applet from NetBeans, there is no problem, everything works fine. But when I try to put it in a web browser, difficulties start : The applet launch all its "stuff" (excuse my vocabulary), but is stuck in the phase when it prints "Switching Applet". And then nothing happens. Here is the code of my applet :

import java.awt.*;
import javax.swing.*;
import java.lang.*;
import org.lwjgl.LWJGLException;


public class Test extends java.applet.Applet implements Runnable {

    Thread tr ;
    Gears mCanva ;
    Button mBouton;

    public Test()
    {
        if(tr==null)
        {
            tr = new Thread(this);
            tr.start();
        }
    }

    public void run()
    {
        while (true)
        {
            repaint();
            try
            {
                Thread.sleep(1000);
            }
            catch(InterruptedException e)
            {
            }
        }
    }


    public void init ()
   {
       try
       {
           mBouton = new Button("Hello World") ;
           mBouton.setBounds(0, 0, 200, 20);
           add( mBouton ) ;
           mCanva = new Gears() ;
           mCanva.setBounds(0, 50, 200, 200);
           add(mCanva);
       }
       catch (LWJGLException e)
        {
           JOptionPane.showMessageDialog(null,"Test","Erreur",JOptionPane.ERROR_MESSAGE);
           throw new RuntimeException(e);
        }
   }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void paint(Graphics gsp)
    {
        mCanva.paintGL();
    }

}


Here, Gears is just the AWTGearsCanvas class of which I changed the name.

and here is my HTML code :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>AppletLoader</title>
  </head>
  <body>

  <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="480">
  
    <!-- 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="Test">
    
    <!-- Main Applet Class -->
    <param name="al_main" value="Test">
    
    <!-- logo to paint while loading, will be centered -->
    <param name="al_logo" value="appletlogo.png">
    
    <!-- progressbar to paint while loading. Will be painted on top of logo, width clipped to percentage done -->
    <param name="al_progressbar" value="appletprogress.gif">
    
    <!-- List of Jars to add to classpath -->
    <param name="al_jars" value="lwjgl.jar, jinput.jar, lwjgl_util.jar, Test.jar">
    
    <!-- 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 -->
    
    <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be int or float -->
    <!-- <param name="al_version" value="0.1"> -->
    
    <!-- background color to paint with, defaults to white -->
    <!-- <param name="al_bgcolor" value="000000"> -->
    
    <!-- foreground color to paint with, defaults to black -->
    <!-- <param name="al_fgcolor" value="ffffff"> -->
    
    <!-- error color to paint with, defaults to red -->
    <!-- <param name="al_errorcolor" value="ff0000"> -->
    
    <!-- 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="false">
    
  
  </applet>

  <p>
    if <code>al_debug</code> is true the applet will load and extract resources with a delay, to be able to see the loader process.
  </p>

  </body>
</html>



  Someone has an idea ?


Matzon

is the applet signed?
since you load native code, it must be signed to do that.

You can use our, but it is generally recommended to sign yourself.

http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/applet

TomSuede


  I tried by signing all of the jar files, but this did not help.
  Actually, I did succeed in making it work, but I don't know really how... first, I think my "natives_" jar used lzma, and I did not declar the jlma.jar. That may be the reason. But the strange thing is that when I saw that, I tried from the beginning, just by changing the applet name and... it worked ! So I tried to make it work with the extracted jar files (and replacing the lzma files). I resulted in an applet that work with all jar files, except lwjgl.jar.pack.lzma, that has to stay in a lzma format, else it does not work... I really don't understand...

  I have another question that has nothing to do with my problem :
The AppletLauncher should copy the .dll files to the user's computer, right ? Are the files found in the lzma ? To be concrete, my question is : what files do I need to set in a server in order to make the applet work ?


kappa

yes the AppletLoader copies the dlls to the users computer, you put your natives(dlls) for each operating system inside a .jar.lzma and it will copy them to the users computer and add the location to the Java classpath

notice the html part

<param name="al_windows" value="windows_natives.jar.lzma">
<param name="al_linux" value="linux_natives.jar.lzma">
<param name="al_mac" value="macosx_natives.jar.lzma">
<param name="al_solaris" value="solaris_natives.jar.lzma">

these are the files that contain the natives(dlls) that will be copied to the computer and added to classpath

As for normal jars that contain class's they use .jar.pack.lzma since pack200 only has an effect on jars if they contain classes.

i'd recommend that you test every thing using just .jar's and once your application works comfortably then switch to using pack200 and lzma, it much simpler and less complex. Remember if you are gonna use pack200 then you must repack your jars first then sign them and then pack them.

As for the server you don't need to make any changes to it.

P.S Try to avoid using AWTGLCanvas its better that you use Display.setParent() for applets its faster and more stable. Gears example found here

TomSuede


  OK, Thanks a lot. I will try without any AWTGLCanvas.
  Oh, and if I used the lzma package, it is not from my own intention, I just got exactly what comes with the package LWJGL (quite convenient by the way).