#### Archived

This topic is now archived and is closed to further replies.

# [java] More HTML host woes

This topic is 5563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I did all that, and it gives me this:

java.lang.NoClassDefFoundError: DuelMonsters (wrong name: duelmonsters/DuelMonst
ers)
3)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
at sun.applet.AppletPanel.run(AppletPanel.java:293)

I have the class files in this directory: D:\DuelMonsters\src\duelmonsters And I have the html as this: <applet code = "DuelMonsters.class" width = 1024 height = 768> </html> The HTML file is also in the same directory. I don''t understand what is wrong. The host is in the same directory as the class files, so there should be no problem, right? GRR!!!!! This is frustrating! LOL. Spread the rusty bleen ointment on the blue-red fromato with your thimble carver

##### Share on other sites
what program are you using to build yer java programs???
because i personally use jbuilder and when you create an applet it usually generates the base html code for you.

Also the other errors i cant really say i dont have the code but it looks like its running into several problems on multiple lines of yer code.. designated by the :### (:512 etc after each error deal)

[edited by - Psionic-X on April 2, 2003 12:29:43 PM]

##### Share on other sites
I fixed the HTML host stuff, but now I get these errors:

  java.lang.NullPointerException	at duelmonsters.Deck.<init>(Deck.java:22)	at duelmonsters.DuelMonsters.<init>(DuelMonsters.java:17)	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)	at java.lang.reflect.Constructor.newInstance(Constructor.java:274)	at java.lang.Class.newInstance0(Class.java:306)	at java.lang.Class.newInstance(Class.java:259)	at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)	at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)	at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)	at sun.applet.AppletPanel.run(AppletPanel.java:293)	at java.lang.Thread.run(Thread.java:536)

for this code:

  package duelmonsters;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Deck{  java.util.Random generator = new java.util.Random();  public static int dS;  int arrDeck[];  public Deck(int DeckSize)  {    for (int i = 0; i < DeckSize; i++)    {      arrDeck[i] = generator.nextInt(100);    }//end for    int dS = DeckSize;  }//end Deck()public static String stringifyDeck(Deck arrDeck)  {    return arrDeck.toString();  }}//end Deck

and

  package duelmonsters;import java.applet.*;import java.awt.*;import java.awt.event.*;import duelmonsters.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class DuelMonsters extends Applet{  Deck deck1 = new duelmonsters.Deck(40);  String string = "";  Label test = new Label("test");  public void init()  {    add(test);  }//end init()}//end DuelMonsters

I think my classes are screwed up somehow. I should probably put this project on hold for a while, and do some smaller stuff first. What do you all think?

Spread the rusty bleen ointment on the blue-red fromato with your thimble carver

##### Share on other sites
I think you should try working on a more basic lvl.. judging from yer other post.. youll want to be able to grasp the concepts behind the language to be able to implement them properly. Me personally i have not tried to program any game type programs yet.. because honestly they dont teach you everything they teach you the basis to be able to use everything (2nd semester java in college) so if yer interested you should keep trying to learn.

##### Share on other sites
I find that when I have the concept for a program I want to write, and I am excited about it, then I am motivated to learn the concepts I need to implement it. If this project motivates you to learn, stick with it.

Having said that, the error log you posted tells you exactly where the error occured, so you should start looking there. Specifically:

  java.lang.NullPointerException    at duelmonsters.Deck.<init>(Deck.java:22)

If you look at Deck.java line 22 you will see:

  arrDeck[i] = generator.nextInt(100);

The problem with that line is you have not allocated any memory for the array. You declared the array like this:

  int arrDeck[];

,but before you use it you need to use "new" to allocate some memory, like this:

  arrDeck = new int[DeckSize];

If you put that line just inside your public Deck(int DeckSize) method, your code compiles and runs.

Shawn

[edited by - ShawnO on April 2, 2003 2:12:17 PM]

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631434
• Total Posts
3000051
×