Putting Java Slick game on a website using html

喜你入骨 提交于 2019-12-12 03:46:56

问题


I have made a 2D java game using Slick and it extends StateBasedGame, it does not extend JApplet so it is not really a real application but from the link bellow it shows that StateBasedGame is part of the Slick API and it can be used as an applet if the html code is coded correctly, here is the link:

http://ninjacave.com/slickapplet

I tried modifying it to fit my code and came up with the following:

   <applet code="org.lwjgl.util.applet.AppletLoader" 
        archive="lwjgl_util_applet.jar" 
        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> 

I basically did as the guide said, I made a .jar file of my game in eclipse and called it racegame.jar, I downloaded lwjgl-2.8.5 and I copied the html code from the website and edited it for my game (the code shown above). The lwjgl had made a folder on my desktop, I opened it, went into the folder called jar (which was where all the jar files were kept) and put in my jar file which was racegame.jar, I got the following error when I tried to run the html code:

ClassNotFoundException
org.lwjgl.util.applet.AppletLoader

Does this mean that the AppletLoader cant be found in my lwjgl?


回答1:


This is exactly what it means. So, check the following.

  1. Check that class name you wrote indeed the fully qualified class name of your AppletLoader. What does this AppletLoader… mean? What is the elipsis in the end of the line?
  2. Check that the class in jar lwjgl_util_applet.jar
  3. Check that jar is available from URL like one that you are using for your HTML page but where the page name is replaced by name of the jar, i.e. if your url is http://host/app/my.html, type http://host/app/lwjgl_util_applet.jar in your browser and to download it. If it is not available check why.

Good luck. BTW, do you know that applets are almost obsolete for last almost 10 years? It is just FYI...



来源:https://stackoverflow.com/questions/14222078/putting-java-slick-game-on-a-website-using-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!