2

I have made a GUI in Java using State Based Game, as it extends StateBasedGame and not JApplet its not a true applet, I want to put it on a website and am unsure on how to do this, I have been told that the following code allows me to make this into an applet using html and not having to edit the Java code:

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

  <param name="al_title" value="Ham Blaster"> 
  <param name="al_main" value="org.newdawn.slick.AppletGameContainer"> 
  <param name="game" value="org.javagame.Game">

  <param name="al_jars" value="racegame.jar, lwjgl.jar, slick.jar"> 

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

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

When I run the html code I get the following error on the centre of my screen:

An error occurred while loading the applet. Please contact support to resolve this issue. missing required applet parameter: al_main.

I have looked inside slick for the ApplerGameContainer but I can only find chrome files, I tried putting these in the same directory as the html file but I still get the same error.

If something seems very simple and may seem too obvious to ask me, please tell me because I am new to Java, my previous error with this code was because I did not have my html and lwjgl_util_applet.jar in the same directory, so please tell me anything that may help me.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Rahul Khosla
  • 349
  • 9
  • 21
  • 1
    Applet code requires to define parameters that the applet accepts. I assume you have done but please check, maybe the parameter name is misspelled there. Also, if your object is actually not an applet at all, consider checking maybe Java Web Start could do better for you. – Audrius Meškauskas Jan 12 '13 at 21:20
  • @AudriusMeškauskas Great idea on [Java Web Start](http://stackoverflow.com/tags/java-web-start/info). Trying to cram a free floating GUI into a web page will always be problematic. – Andrew Thompson Jan 13 '13 at 06:35
  • If you still need help on this thread, you can visit one application called [Tables](https://gagandeepbali.uk.to/svn/myrepository/tables/) I had made a long long time back, on this link. Username : guest and Password : guest, for the link, you can see my project structure in that, and all the files and source code, a simple project though :-), most of the thingies are in the bin folder. That's the [link](http://gagandeepbali.uk.to/gaganisonline/swing/tables/tables/bin/tableapplet.html) where it is running, though for all the links to work, my computer must be ON, since it's the server here. – nIcE cOw Jan 19 '13 at 17:57

1 Answers1

1

Emm...

I am not pretty sure, but according to sources the error comes from init method

/*
     * @see java.applet.Applet#init()
     */
    public void init() {
        state = STATE_INIT;

        // sanity check
        String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"};
        for(int i=0; i<requiredArgs.length; i++) {
            if(getParameter(requiredArgs[i]) == null) {
                fatalErrorOccured("missing required applet parameter: " + requiredArgs[i], null);
                return;             
                }

//...           }       
        }

so it seems your al_main param value is null or something :S

The problem is maybe someplace here

<param name="al_main" value="org.newdawn.slick.AppletGameContainer"> 

... maybe because I don't see you to init all the rest required params as "al_logo", "al_progressbar"

Anyways, it would be more helpful you to show the problem code


Report if it helps

user592704
  • 3,674
  • 11
  • 70
  • 107