简体   繁体   中英

Running applet in browser

I know that the question has been asked many times, but I have problem that I could not solve normaly. I am codeing a RPG game and I would to run in self-standing in browser. the DIR looks like:

C:\Users\Tomasz\SimpleRPG

that is main folder of project, but I have here .settings bin and src folders, and in each i have package foldes rpg . I have found code to run it from HTML:

<applet code=main.class name=main archive=main.jar
    width=640 height=640>
    <param name="bgcolor" value="ffffff">
    <param name="fontcolor" value="000000">
    Your browser is not Java enabled.
</applet>

I am wondering where to put that file to run it. When I drop it to bin/rpg , it brings me error:

NoClassDefFoundError: main (wrong name: rpg/main)

If I drop it to src/rpg I have another error:

ClassNotFoundException: main.class

And if I copy all .class and all .java to one folder SimpleRPG/all and drop script there:

NoClassDefFoundError: main (wrong name: rpg/main)

I have to say that I have also graphics in that project in bin/img .

Can some one advise me what to do?

It seems the class file is located in the rpg package. So the applet element should be more along the lines of:

<applet code='rpg.main' 
    name='main' 
    archive='main.jar'
    width='640' height='640'>
    <param name="bgcolor" value="ffffff">
    <param name="fontcolor" value="000000">
    Your browser is not Java enabled.
</applet>

This should work if main.jar is in the same directory as the HTML that loads it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM