Q:1 How do we write a Java program?
1. Open an editor (Notepad).
2. Write a program.
class FirstProgram{
public static void main(String [] args) {
System.out.println("Name :- JTC");
System.out.println("email :- jtc@jtcindia.org");
System.out.println("job :- software");
System.out.println("Favourite subject :- Computer science");
}
}
Name :- JTC email :- jtc@jtcindia.org" job :- software Favourite subject :- Computer science
Q:2 How do we save a Java program?
Save the program (File).
• Select the destination (location) [JTC Folder]
• Write the file name.
• Save with ".java" extension
• Click on save button.
Note:
We cannot save the Java source code with space.
Q:3 How do we compile our Java Program?
1. Open the command prompt.
2. Move to that directory where we have saved out .java file [JTC Folder]
• cd OneDrive
• cd desktop
• cd JTC
• cd OneDrive/desktop/JTC
Move to JTC folder manually (on click) then
• Select the directory path
• Type cmd
• Press Enter
javac FirstProgram.java
Note: FirstProgram.java is a file in class example
Note: If compiler gets any mistake in code, then we get err message on cmd along with the line no.
Note: If compiler id does not get any error, then we get a .class file on same location [JTC].
Q:4 How we can run our Java Program?
After successful program compilation, as you can see in the above image, we have a .class file which is FirstProgram.class and now we can proceed to run the Program.