Applet Clubie...

Hi all,

I’ve been going through the tutorials on Slick Wiki.

I’m working on Spin’s applet tutorial. Like the basic app in the tut’, I have a Slick clock application, that I want to display on my web page.

Image:

http://sphotos.ak.fbcdn.net/hphotos-ak-ash2/hs102.ash2/38433_413231356716_555931716_5191969_6396352_n.jpg

When running it locally, this works fine. However, after three restart-from-scratch attempts at following the applet tutorial, I’m getting the following error:

Image:

http://sphotos.ak.fbcdn.net/hphotos-ak-ash2/hs035.ash2/35109_413232316716_555931716_5191988_625491_n.jpg

How do I find out what is going wrong here? I don’t know how to debug this.

Halp!
:slight_smile:

Can you provide the output of the java console?

Would also be really helpful if you could provided a link to the applet so as to allow a closer look. If you not then at least a copy of the html.

I’ve just uploaded the site it to my server.

gameworks.ravensbridge.com

It will hopefully be a development blog and graphics showcase… eventually :slight_smile:

Edit:
It seems to work fine on my local host… Let me have a look at that…

Sorry, how do I do that? ::slight_smile:

according to the java console you seem to be missing

http://gameworks.ravensbridge.com/apps/lwjgl.jar.pack.lzma

tried to access that file directly, doesn’t seem to be on the server.

Ahh, ok… let me go upload that

Edit:

Uploading that file (it seems to already be on the server however) didn’t make a difference. I’ve decided to upload the whole ‘app’ directory from my local server, which seems to work ok.

shock and you call yourself a java developer :slight_smile:

anyway when developing applets, usually useful to just show the java console always. This is done by enabling it in the java control panel (found in windows control panel on windows).

Once in the java control panel, click the advanced tab -> show java console -> and check java console.

now everytime you run a java applet in the browser the java console will pop up.

Alternatively to manually show it, you can right click the java icon in the system tray when running an applet, then just choose show java console.

Haha, yeh… I thought you meant the Java Console in the browser (like firebug) ;D

Cheers for that though, It will be helpfull

Ok, this is really weird…

Locally, this works fine.

On the remote server, it does not work because the file is missing.

Both directory structures and files are Exactly the same.

Could there be something happening that I don’t know about?

This may be a ‘duhh’ moment, but I don’t need to install anything on the server to allow it to give out applets right? Like PHP needs to be installed to allow parsing php scripts?

nope you don’t need to do anything on the server.

however the link http://gameworks.ravensbridge.com/apps/lwjgl.jar.pack.lzma is still dead (as you can see by clicking it) and this is one of the files your applet is pointing to in the html (at http://gameworks.ravensbridge.com/apps/countdownTimerApp.html).


java.io.FileNotFoundExceptions for:

http://gameworks.ravensbridge.com/apps/apps/lwjgl_util_applet.jar
http://gameworks.ravensbridge.com/apps/apps/lzma.jar

Note: /apps/apps/

Some files exist in /apps/apps/ and some in /apps/

uuuh… I cant believe that i did not spot that…

Now why is that happening?

 <applet code="org.lwjgl.util.applet.AppletLoader"
            archive="lwjgl_util_applet.jar, lzma.jar"
            codebase="./apps/"
            width="730" height="110">
 
      <!-- 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="NixieTimer">
 
      <!-- Main Applet Class -->
      <param name="al_main"
             value="org.newdawn.slick.AppletGameContainer">
      <param name="game"
             value="DecoGame_NixieClock.NixieClockGame">
 
      <!-- 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="slick.jar, NixieClock.jar, lwjgl.jar.pack.lzma, jinput.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 -->
 
      <!-- 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>

I don’t exactly understand what some of this is for, but the only time that directories are set is at


<applet code="org.lwjgl.util.applet.AppletLoader"
            archive="lwjgl_util_applet.jar, lzma.jar"
            codebase="./apps/"
            width="730" height="110">

so where does the ‘apps/apps/’ come from?

EDIT:
Ok, so I get the same error message locally, but the applet displays properly regardless… I’m going to try moving the files to the ‘apps/apps/’ directory to see if that makes any difference.

I don’t really like to do that though… I’d rather understand why it is so.

why not start with something simple first by just putting everything in one directory (including html) so you don’t have to be look in other directories or paths. You can then move to something more complex like you have now by using the frame/javascript stuff. Should make it easier to get it all just working.

http://gameworks.ravensbridge.com/apps/countdownTimerApp.html

there’s the page that I’m AJAXing in. I generally make my web pages that way out of habit. Navigating to that page directly has the same result.

I’m going to start again and throw together a bare bones test…
10 mins…

well using that page it fails with an error about not finding slick.jar, this is looked for at
http://gameworks.ravensbridge.com/app/app/slick.jar due to the ./app/ bit in the applet tag and as thats not a valid link, it fails to load.

the ‘.’ means current path (http://gameworks.ravensbridge.com/app) plus “/app/”

ok, i’m putting everything in the root directory and setting the the codebase attribute to

codebase=""

if that does not work, i’ll try using an absolute url…

you’ll want to set it to

codebase="."

Thanks for all your help guys.

I’ll give that a try.

Then I’m going to leave this for the moment - my FTP client is being an ass, my server keeps disconnecting and I’m getting pretty fed up with dealing with it rather than getting on with actual game work, so I’m going to call it a night and try again in the morning.

Cheers,
Matt

Ok, I’ve started again from scratch this morning.

My HTML page:


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

  <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar, lzma.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="TestApplet">
    
    <!-- Main Applet Class -->
    <param name="al_main" value="TestAmpplet.myApplet.Main">
    
    <!-- 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_applet.jar.pack.lzma, lwjgl.jar.pack.lzma, jinput.jar.pack.lzma, lwjgl_util.jar.pack.lzma, res.jar.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">
  	
  	<param name="separate_jvm" value="true">
  </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>


My Applet’s Main class:


package myApplet;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.SlickException;


/**
 *
 * @author Administrator
 */

  public class Main {

    private static AppGameContainer app;

    private static TestApplet sg;
    
    public static void main(String[] args) throws SlickException
    {
        
        
        sg = new TestApplet();
        app = new AppGameContainer(sg);
        
        app.setDisplayMode(640, 480, false);
        app.start();


    }   
}

My Game Class:


package myApplet;

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

/**
 * Class Name:
 * Description:
 * Author Administrator
 * Date Created: Jul 20, 2010
 * (See and of class for change-log)
 */
public class TestApplet extends BasicGame{

    public TestApplet()
    {
        super("Ravensbride Gameworks: Nixie Clock");
    }

    @Override
    public void init(GameContainer gc) throws SlickException {

    }

    @Override
    public void update(GameContainer gc, int i) throws SlickException {
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            Logger.getLogger(TestApplet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void render(GameContainer gc, Graphics g) throws SlickException {
        g.drawString(new Date().toGMTString(), 10, 40);
    }
}

The console output i’m getting this time (different)



Loaded image: jar:http://localhost/gameworks/apps/testApp/lwjgl_util_applet.jar!/appletlogo.png
Loaded image: jar:http://localhost/gameworks/apps/testApp/lwjgl_util_applet.jar!/appletprogress.gif
This occurred while 'Switching applet'
java.lang.ClassNotFoundException: TestAppplet.myApplet.Main
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:943)
	at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:751)
	at java.lang.Thread.run(Unknown Source)

Can anyone shed any light on what is going on here?

your using Slick2D so this line is incorrect

<param name="al_main" value="TestAmpplet.myApplet.Main">

When using slick2D the al_main should be “org.newdawn.slick.AppletGameContainer” and you should use the game parameter to tell Slick2D what is your main class.

So you should use

<param name="al_main" value="org.newdawn.slick.AppletGameContainer">
<param name="game" value="TestAmpplet.myApplet.Main">

Ahh, ok.

Now I get the following error…


Loaded image: jar:http://localhost/gameworks/apps/testApp/lwjgl_util_applet.jar!/appletlogo.png
Loaded image: jar:http://localhost/gameworks/apps/testApp/lwjgl_util_applet.jar!/appletprogress.gif
This occurred while 'Switching applet'
java.lang.ClassNotFoundException: org.newdawn.slick.AppletGameContainer
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:943)
	at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:751)
	at java.lang.Thread.run(Unknown Source)

I think the problem is that I just really don’t understand what any of this means. Does anyone know of any Slick Applet tutorials that go into what is happening in more detail?