Code won't run on my computer but works fine on school's computers
4 replies, posted
I want to finish something we've been working on in class.
[code]import java.awt.*;
import java.applet.*;
public class LAB04GRFX01st extends Applet
{
public void paint(Graphics g)
{
//DRAW CUBE
g.drawRect(20,20,300,300);
g.drawLine(20,320,64,364);
g.drawLine(20,20,64,64);
g.drawLine(320,20,364,64);
g.drawLine(320,320,364,364);
g.drawRect(64,64,300,300);
}
}[/code]
Compiles fine but whenever I run it it gives me
[quote=JCreator]java.lang.NoSuchMethodError: main
Exception in thread "main"[/quote]
It runs just fine on the school's computers. Same exact code. :v:
Hmmmm... ask one of your teachers.
Is it the same exact file? Is it on a jump drive?
You need to run it as an applet and not as a java application.
To run the above code you'll have to embed it into a html file or have an IDE to do that for you. See [url=http://download.oracle.com/javase/tutorial/deployment/applet/]this[/url].
[quote]An applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the java.applet.Applet class. The Applet class provides the standard interface between the applet and the browser environment.[/quote]
What IDE are you using? (netbeans, eclipse, other)
[QUOTE=Borsty;24890967]You need to run it as an applet and not as a java application.
To run the above code you'll have to embed it into a html file or have an IDE to do that for you. See [url=http://download.oracle.com/javase/tutorial/deployment/applet/]this[/url].
What IDE are you using? (netbeans, eclipse, other)[/QUOTE]
Ok, fuck me. I forgot about running it in an HTML file.
Never mind, false alarm.
Sorry, you need to Log In to post a reply to this thread.