What is Java?
Java is a general-purpose, class-based, object-oriented programming language designed for having lesser implementation dependencies. It is a computing platform for application development. Java is fast, secure, and reliable, therefore. It is widely used for developing Java applications in laptops, data centers, game consoles, scientific supercomputers, cell phones, etc.
Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. … Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture.
What is Java Platform?
Java Platform is a collection of programs that help programmers to develop and run Java programming applications efficiently. It includes an execution engine, a compiler, and a set of libraries in it. It is a set of computer software and specifications. James Gosling developed the Java platform at Sun Microsystems, and the Oracle Corporation later acquired it.
WHAT IS A COMPILER?
In computing, a compiler is a computer program that translates computer code written in one programming language into another language. The name “compiler” is primarily used for programs that translate source code from a high-level programming language to a lower level language to create an executable program.
TYPES OF COMPILERS
Compilers are divided into three parts 1) Single Pass Compilers 2)Two Pass Compilers, and 3) Multipass Compilers. The “compiler” was word first used in the early 1950s by Grace Murray Hopper. Steps for Language processing system are: Preprocessor, Interpreter, Assembler, Linker/Loader.
WHAT IS NOTEPAD?
Notepad is a simple text editor for Microsoft Windows and a basic text-editing program which enables computer users to create documents. It was first released as a mouse-based MS-DOS program in 1983, and has been included in all versions of Microsoft Windows since Windows 1.0 in 1985.
How many types of notepad are there?Microsoft Notepad
New Notepad on Windows 10 | |
---|---|
Operating system | Microsoft Windows |
Platform | IA-32, x86-64, and ARM (historically Itanium, DEC Alpha, MIPS, and PowerPC) |
Predecessor | MS-DOS Editor |
Type | Text editor |
HOW TO COMPILE AND RUN JAVA PROGRAMME IN NOTEPAD
Before running (execute) a Java program, ensure that Java is installed in the system and the path is properly set. If the path is not properly set, we cannot run the Java program.
We must follow the steps given below to run a Java program.
- Open the notepad and write a Java program into it.
- Save the Java program by using the class name followed by .java extension.
- Open the CMD, type the commands and run the Java program.
Let’s create a Java program and run it using the Command Prompt.
Note: We are considering that Java is properly installed and the path is properly set in your system.
Step 1: Open the notepad by pressing the Windows Key + R, type notepad and press enter key, or click on the Ok button. It opens the notepad.
Step 2: Write a Java program that you want to compile and run. We have written the following code in the notepad.
CharArrayToStringExample.java
- public class CharArrayToStringExample
- {
- public static void main(String args[])
- {
- //character array
- char[] ch = {‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’, ‘ ‘ , ‘t’, ‘o’, ‘ ‘, ‘J’, ‘a’, ‘v’, ‘a’, ‘t’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’};
- //constructor of the String class that parses char array as a parameter
- String string = new String(ch);
- //prints the string
- System.out.println(string);
- }
- }
Step 3: To save a Java program press Ctrl + S key and provide the file name. Remember that the file name must be the same as the class name followed by the .java extension.
If you are writing the same Java program (as above) save it by providing the file name CharArrayToStringExample.java press enter key or click on the Save button.
We have saved the above program at the location C:\demo.
Now, we have created and saved the Java program. In the next step, we will compile and run the Java program.
Step 4: To compile and run a Java program, open the Command Prompt by pressing Windows Key + R, type cmd and press enter key or click on the Ok button. It opens the Command Prompt window.
Step 5: In the Command Prompt window, write the following commands.
- cd\
- cd demo
Now we are inside the demo folder where we have saved the Java program.
Step 6: To compile the Java program type the following command:
javac CharArrayToStringExample.java
When we compile a Java program without any error, it creates a .class file with the same name as the file name at the same location (where the program is saved).
Step 7: To run the Java program, type the following command.
java CharArrayToStringExample
Note that we have not written .java after the file name.
In the above image, welcome to Javatpoint is the output of the program.
Drop your comment