问题
I tried following this to export my libGDX game as a Java applet. The guide was a bit confusing so I might have done something wrong here. This is what I did:
My libGDX game, in Eclipse, looks like this:
Game
Game-Android
Game-Desktop
The desktop game works fine.
As the guide says, the desktop project uses the Lwjgl backend.
Then I created a GameApplet.java
in Game-Desktop/src/my.package.name
containing
package my.package.name;
import com.badlogic.gdx.backends.lwjgl.LwjglApplet;
public class GameApplet extends LwjglApplet
{
private static final long serialVersionUID = 1L;
public GameApplet()
{
super(new Game(), false);
}
}
I created a directory applet
in Game
containing
gdx.jar
gdx-backend-lwjgl.jar
gdx-backend-lwjgl-natives.jar
gdx-natives.jar
lwjgl_util_applet.jar
I right-clicked Game
in Eclipse and exported it as a JAR with the following settings:
Resources to export:
- Game
-- src
-- libs
Export generated class files and resources
The exported JAR (called Applet.jar
) was placed in the applet
folder.
I created the index.html
file containing
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>HelloApplet!</title>
</head>
<body>
<div id="applet_container">
<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="480">
<param name="al_title" value="HelloApplet">
<param name="al_main" value="my.package.name.GameApplet">
<param name="al_bgcolor" value="000000">
<param name="al_fgcolor" value="ffffff">
<param name="al_jars" value="Applet.jar, gdx.jar, gdx-backend-lwjgl.jar">
<param name="al_windows" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="al_linux" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="al_mac" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="al_solaris" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="codebase_lookup" value="false">
<param name="java_arguments" value="-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false -Xmx800M">
<param name="lwjgl_arguments" value="-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true">
<param name="separate_jvm" value="true">
<param name="codebase_lookup" value="false">
</applet>
</div>
</body>
</html>
I signed the files and uploaded them to my site. On Firefox, OSX, I get a message saying
ClassNotFoundException
org.lwjgl.util.applet.AppletLoader
What did I do wrong?
来源:https://stackoverflow.com/questions/20541236/classnotfound-for-appletloader-when-exporting-a-libgdx-applet