Extended Runtime

Use of Static keyword in Java?
My class compiles OK but at runtime I get a ‘class does not have a main method’ error. Could this be because I didn’t declare it static? the problem is if I declare it static I get methods that cannot be referenced from a static context. See following code example:
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame
{
public void main(String[] args)
{
Frame frame = new Test();
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose(); System.exit(0);}
}
);
}
}
What exactly is wrong with this?
static functions or variables don’t need to your class be instantaned. in your example public void main is a subroutine and it can be called if your class instantaned like
Test t=new Test();
t.main(new String[] {“1″,”2″,…});
in command line when you type
$> java Test
your class is not an object, so java interpreter can call the static main subroutine without declaring an object from your class. so you have to declare it as public static void main…
|
|
HP R5500 VA Extended Runtime Module AF417A Uninterrupta £817.13 |
|
|
Borri B300-01L 10000Va 1KVa Tower UPS with 2 x Extended runtime battery units £1,080.00 |
|
|
AF434A – HP UPS Extended Runtime Module – battery encl £969.99 |
|
|
AF455A HP Extended Runtime Module – Battery enclosure ( £1,101.29 |
|
|
AF464A HP UPS Extended Runtime Module – Battery enclosu £1,255.70 |
|
|
COMPAQ UPS Part 218968-001 EXTENDED RUNTIME MODULE £0.99 |
|
|
AF464A – HP UPS Extended Runtime Module – battery encl £672.99 |
|
|
HP UPS R8000/3 R12000/3 Extended Runtime Module-102115 £993.74 |
|
|
APC SURTD3000XLI Smart-UPS 3000VA 230V Extended Runtime £1,595.79 |
|
|
DELL Vostro 1310 1510 Battery 85WHR Extended RunTime G276C G274C T116C £49.99 |
|
|
Two Extended RunTime Battery Fit Dewalt DW0240 24V,2.4A £117.58 |
|
|
Extended Runtime Battery For Ryobi 1400672 18V 18volt £28.78 |
|
|
AF455A HP Extended Runtime Battery Module Kit for HP R/T3000 Uninterruptible Pow £985.90 |
|
|
18V 3.0Ah Extended Runtime Battery For Dewalt DW9096 £53.67 |
|
|
HP Extended Runtime Battery Module Kit for HP R/T3000 Uninterruptible Power £951.62 |
|
|
18V 2.2Ah Extended Runtime Battery For Makita 1834 £39.08 |
|
|
2x18V 3.0Ah Extended Runtime Battery For Dewalt DW919 DCG411KL £105.34 |
|
|
HP R5KVA and R7KVA 3U Extended Runtime Module-328831 £681.44 |
|
|
2x18V 3.0Ah Extended Runtime Battery For Dewalt DW933 £105.34 |
|
|
Two 18V 3.0A Extended Runtime Battery For Dewalt DW9096 18 volt £105.34 |
|
|
2x18V 3.0Ah Extended Runtime Battery For Dewalt DW9096 18 volt £105.34 |
|
|
HP R/T3000 2U Extended Runtime Module: AF455A-212639 £962.19 |
|
|
Two Extended Runtime Battery For Dewalt DW9095 18V,2.2A £75.98 |
Surefire E2D LED Defender