Introduction: Java Basics

Learn to Use Java

Step 1: Open Notepad

Step 2: Enter the Code

In writing a java program, it always begin with public class _________(Enter the name of your Program)

Then Write the code provided

public class Sample
{ public static void main(String args[])

{

System.out.println("Hi...This is my First Java Program");

}

}


It is necessary that you should all the things given above or simply copy them

Step 3: Saving It

When you are going to save a java program, it is necessary to write the same name which you have written in the class name with a '.java' extension

Step 4: Running a Program

Then you have to open cmd

For opening cmd just type it in the search box and do the following steps

  1. Navigate to the place where you saved your program in cmd
  2. Then type 'set path=C:\Program Files\Java\jdk1.8.0_101\bin' but change the version according to your jdk.
  3. Press Enter
  4. Then type 'javac'
  5. Then type 'javac Sample.java' Where I have type Sample.java you have to replace it with your file name
  6. If any errors were there then it would be shown on the screen.
  7. After correcting those errors do the 5th step again.
  8. Type 'java Sample' Where I have type Sample you have to replace it with your file name.
  9. Your program is ready

Step 5: Important Points

  1. Your class name should start with a capital letter
  2. While typing your message, you should add inverted commas or it will show errors
  3. After typing your message, add a colon (;).

I hope you like this ...

Thanks

Comments

author
DIY Hacks and How Tos (author)2016-11-06

Great first instructable. Very well written.

About This Instructable

352views

20favorites

More by Pranav Tyagi:BATCH CRACKERShutdown using cmdJava Basics
Add instructable to: