0

So I'm trying to run a little applet I made using Slick 2D on my website. I've wrote the following HTML and put it on a new page on my site

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

    <param name="al_title" value="myslickgame"> 
    <param name="al_main" value="org.newdawn.slick.AppletGameContainer"> 
    <param name="game" value="org.defaultpackage.main">

    <param name="al_jars" value="spacewalk.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> 

However, whenever I load that page I get a class not found error. I've added the lwjgl.util.applet JAR and my applet JAR to the public_html folder but it still doesn't seem to be reading them. Its a wordpress site if that matters. I tried to find where the heck WordPress stores its data for pages so I could stick the JARs in that folder but no such luck. Any help guys? Thanks in advance

Nile
  • 25
  • 2
  • 11
  • 1
    I'm not experienced with Java, but isn't `codebase` supposed to be `/path/to/publich_html` instead of `.`(which I presume selects the current directory)? – Nikola Ivanov Nikolov Nov 27 '12 at 08:37

1 Answers1

0

I think this is possibly because you need to have the native jar files on the website also (for the operating system you are using).

Make sure you have the jar files (or at least the one for your operating system):

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

in the same directory as the html file.

You can find the files to make this jar yourself inside of the lwjgl natives folder, the windows_natives.jar should contains these files:

jinput-dx8.dll
jinput-dx8_64.dll
jinput-raw.dll
jinput-raw_64.dll
lwjgl.dll
lwjgl64.dll
OpenAL32.dll
OpenAL64.dll

Just toss those into a new .zip folder and then rename it to the .jar extension The other native jars (linux, mac, solaris) should contain their respective native files from the lwjgl distribution.

My folder structure for using lwjgl is like so:

index.html
jinput.jar
linux_natives.jar
lwjgl.jar
lwjgl_util.jar
lwjgl_util_applet.jar
mjgame.jar (the java game jar)
slick-util.jar
windows_natives.jar

If this isn't the answer to the problem perhaps you could post a copy of the exception you are receiving and we can debug this problem further.

Also, you don't need to upload the files onto the website in order to test if you have the files setup properly. You can simply open the html file from your local disk in your internet browser and it should work.

I know how frustrating this can be to figure out, it took me a week to figure out why I wasn't doing this right the first time.

Good luck!


- Edit -

I'm pretty sure you have to sign the jar files also, or you may get a black screen. You will need to use keytool and jarsigner from your JavaSDK bin folder, which could look like this:

C:/Program Files/Java/jdk1.7.0_07/bin

Here is a tutorial page on signing jar files:

https://www.owasp.org/index.php/Signing_jar_files_with_jarsigner

You need to first create a keystore file, to store the certificate information (from what I understand) You can do this with this command:

keytool -genkey -keystore testkeystore -alias bob

^ testkeystore - is the file that the certificate information is stored in ^ bob - the alias name you decide

Then you can sign jar files with the jarsigner tool:

jarsigner -keystore testkeystore -signedjar mysignedjar.jar targetjar.jar bob

^ targetjar.jar - the jarfile you want to sign ^ mysignedjar.jar - the output jarfile that will be a signed copy of targetjar.jar

Out of the file structure that I had from above, I signed all the jar files:

jinput.jar
linux_natives.jar
lwjgl.jar
lwjgl_util.jar
lwjgl_util_applet.jar
mjgame.jar (the java game jar)
slick-util.jar
windows_natives.jar

This should solve your blank screen problem after signing all the jars. If it doesn't work out for you leave some feedback and we will figure this out and maybe write a step by step answer.

demon_ds1
  • 164
  • 1
  • 7
  • Whoa! Wasn't getting any answers and I totally forgot about this. I don't know how I missed your reply before. I'll try your advice out and let you know how it goes. Thanks! – Nile Dec 04 '12 at 15:54
  • Hmm okay. I've got all my files that you've listed. Using the jars from lwjgl 2.8.5 (latest version) I simply showed up with nothing so I though maybe Slick is still using 2.8.4 as 2.8.5 is new. So I put in the jars from the 2.8.4 library but this time I recieved an error while "downloading packages" – Nile Dec 05 '12 at 08:03
  • Hey there! Two weeks later I reply again haha! I'm pretty sure the reason it is showing blank now, is because you need to sign all your jars with certificates. https://www.owasp.org/index.php/Signing_jar_files_with_jarsigner I have a netbeans build.xml file that automates my jar signing for me at build time, I will post it in a minute once I find it. Edit: I am going to add the newer answer in the original answer reply above. – demon_ds1 Dec 20 '12 at 15:46
  • Oh boy, signed and still nada. Here's my HTML http://pastebin.com/Pt0tsihE And here's a snap of what's in the root of my folder http://imgur.com/Agsr0 I am following this tutorial http://www.slick2d.org/wiki/index.php/Spins_tutorials/02_-_A_Basic_Slick_Applet – Nile Dec 23 '12 at 07:26
  • Also, the tutorial says I need to extract the lwjgl.jar and jinput.jar from the lwjgl applet .lzma files but extracting lzma with 7-zip ends with a dead end, so I just grabbed those two jars from the lwjgl 2.8.5 build. Possible source of the error? To be clear I am still getting a blank screen – Nile Dec 23 '12 at 07:31
  • I see some differences in the tutorial you are following and the way that I am doing mine. The main difference I see right away is that you're html file is using the "game" parameter set to "org.myorg.SpaceWalk.SpaceWalk". I don't even use the game parameter in mine, I just point "al_main" to my main class "com.mjgame.launcher.TheApplet". I will follow the tutorial you are using and see if I can figure out what is going wrong here. – demon_ds1 Dec 23 '12 at 18:28
  • Unfortunately I'm not able to get to my home computer until after the holidays. I will take a look at it around the 1st of January and post my findings for you to look at. Merry Christmas! – demon_ds1 Dec 23 '12 at 18:29
  • Oh I was just thinking, you can also enable the Java Console so that you can see what is going wrong when you launch it in the browser. http://www.java.com/en/download/help/javaconsole.xml – demon_ds1 Dec 23 '12 at 18:38
  • Merry Christmas! I ran the console (nice tip) here is the error, I recieved http://pastebin.com/jcmNLBCP – Nile Dec 23 '12 at 21:42
  • EDITED: Have you made any progress on this? I Just took a look at the pastebin and the error java.lang.ClassNotFoundException: org.myorg.SpaceWalk.SpaceWalk really stands out lol. Perhaps it would be faster if you sent me a zipped copy of your project and I can see if I can get it to work? My spam email is ___________, I removed the email from this comment to avoid spam. Worse comes to worse I can give you one of my examples that work and you can go from there. – demon_ds1 Jan 31 '13 at 02:12