java not working!!

October 8, 2010 at 22:12:07
Specs: Windows XP
I just started learning java. I downloaded the latest java jdk and installed it. This is how I set the variables. "control panel>system>advanced>environment variables. then created a new variable called path and gave the path of BIN folder of JDK as the value. Then I opened CMD and typed JAVAC. It displayed some stuffs. BUT, the problem is I wrote a small java code like this
Code:

class hello
{
public static void main (String args[])
{
System.out.println("welcome");
}
}

I saved this as MyFirstApp.java

when there were errors CMD showed them to me. But when there were no errors, nothing happens!! It just compile the file and comes back to the "c:\" directory without any output. why is that? Did I do something wrong? please help me sooooon!! Thank you.


See More: java not working!!

Report •

#1
October 18, 2010 at 20:59:34
The name of the file should be the same with the name of the class.
In your case, save it as hello.java instead of MyFirstApp.java.
Then
Compile it: javac hello.java
Run it: java hello

Good luck.


Report •
Related Solutions


Ask Question