Jump to content
  • Advertisement

Archived

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

fadilthrejk

[java] More HTML host woes

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I did all that, and it gives me this:
  
java.lang.NoClassDefFoundError: DuelMonsters (wrong name: duelmonsters/DuelMonst
ers)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
        at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)
        at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
        at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
        at sun.applet.AppletPanel.run(AppletPanel.java:293)
        at java.lang.Thread.run(Thread.java:536)
  
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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!