Virtual Position Forum
Please register to watch content in detail
Thanks
Admin virtual position


Join the forum, it's quick and easy

Virtual Position Forum
Please register to watch content in detail
Thanks
Admin virtual position
Virtual Position Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

how can we run the java code ? after saving the file how run it?

View previous topic View next topic Go down

GMT + 3 Hours how can we run the java code ? after saving the file how run it?

Post by Diya Sun May 29, 2011 3:10 pm

how can we run the java code ? after saving the file how run it?
Diya
Diya
Monstars
Monstars

Taurus Goat
Posts : 364
Join date : 2011-02-08
Age : 33
Notworthy

Character sheet
Experience:
how can we run the java code ? after saving the file how run it? Left_bar_bleue10/500how can we run the java code ? after saving the file how run it? Empty_bar_bleue  (10/500)

Back to top Go down

GMT + 3 Hours Re: how can we run the java code ? after saving the file how run it?

Post by Vuhelper Sun May 29, 2011 3:11 pm

* Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text:

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

Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java.

* Run Command Prompt (found under All Programs/Accessories in the Start menu). Type

C:\> cd \mywork

This makes C:\mywork the current directory.

C:\mywork> dir

This displays the directory contents. You should see HelloWorld.java among the files.

C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin

This tells the system where to find JDK programs.

C:\mywork> javac HelloWorld.java

This runs javac.exe, the compiler. You should see nothing but the next system prompt...

C:\mywork> dir

javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.

C:\mywork> java HelloWorld

This runs the Java interpreter. You should see the program output:

Hello, World!

If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!
avatar
Vuhelper
Deep Bench
Deep Bench

Posts : 97
Join date : 2011-05-29

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum