Java error in the first step & ldquo; Hello World & rdquo;

advertisements

I have an error in my first step with Java, so when i try to run the code hello world:

class apples{
    public static void main(String args[]){
        System.out.println("Hello World!");
    }
}

I go to: - Run as .. -> Then i choose Java aplicacion - > And i press Ok (http://yfrog.com/joerror2np)

But when i press Ok does not appear the window down to show me the correct message Hello World, so i get the error of screenshot http://yfrog.com/5merror3zp


Your code works fine for me:

class apples
{
    public static void main(String args[])
    {
        System.out.println("Hello World!");
    }
}

I downloaded it to c:\temp\apples.java.

Here's how I compiled and ran it:

C:\temp>javac -cp . apples.java

C:\temp>dir apples
 Volume in drive C is HP_PAVILION
 Volume Serial Number is 0200-EE0C

 Directory of C:\temp

C:\temp>dir ap*
 Volume in drive C is HP_PAVILION
 Volume Serial Number is 0200-EE0C

 Directory of C:\temp

08/15/2010  09:15 PM               418 apples.class
08/15/2010  09:15 PM               123 apples.java
               2 File(s)            541 bytes
               0 Dir(s)  107,868,696,576 bytes free

C:\temp>java -cp . apples
Hello World!

C:\temp>

Your lack of understanding and the IDE appear to be impeding your progress. Do simple things without the IDE for a while until you get the hang of it. A command shell and a text editor will be sufficient.

Sorry about missing javac; cut & paste error.