how can we run the java code ? after saving the file how run it?
Virtual Position Forum :: Members Lounge :: Sciences & Knowledge :: Programing and Design :: Java Forum
Page 1 of 1 • Share
how can we run the java code ? after saving the file how run it?
how can we run the java code ? after saving the file how run it?
Diya- Monstars
-
Posts : 364
Join date : 2011-02-08
Age : 33
Character sheet
Experience:
(10/500)
Re: how can we run the java code ? after saving the file how run it?
* 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!
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!
Vuhelper- Deep Bench
- Posts : 97
Join date : 2011-05-29
Similar topics
» How can we make java "class" file as exe file. So that we could run it directly witho
» Java Complied File
» Native code in java
» need guidness in java code
» little error in java code
» Java Complied File
» Native code in java
» need guidness in java code
» little error in java code
Virtual Position Forum :: Members Lounge :: Sciences & Knowledge :: Programing and Design :: Java Forum
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Thu Nov 21, 2024 6:50 pm by ali001
» AMERICA EARNS! - Gift Card App
Mon Nov 18, 2024 11:07 am by ali001
» Kanba - Manage your Tasks
Thu Nov 14, 2024 12:21 pm by ali001
» Hemangiom'App
Tue Nov 05, 2024 11:25 am by ali001
» MindfulMe - Mental Health App
Mon Nov 04, 2024 10:50 am by ali001
» Learn Candlestick Patterns
Tue Oct 15, 2024 5:51 am by ali001
» Woh Pagal Si Episode 52 to 62 - Top Pakistani Drama
Sat Sep 21, 2024 6:26 pm by Mir Emmad Ali Khan Domki
» Nearu - share your socials
Sat Sep 21, 2024 1:12 pm by ali001
» Nightclub Tycoon: Idle Empire
Thu Sep 19, 2024 9:16 pm by ali001