Basic requirements for writing a simple Java program
Java Development Kit (JDK): You need to have a JDK installed on your system to run a Java program. JDK is a collection of programming tools and software needed to develop and run Java applications. You can download and install the JDK from the official website of Oracle. click here to learn how to install the JDK toolkit
Text Editor (windows Notepad) or IDE: You need a text editor or an Integrated Development Environment (IDE) to write your Java code. There are many free and paid options available, such as Eclipse, IntelliJ IDEA, NetBeans and Notepad++
Setting up environment variables: You need to set up the environment variables for Java on your system. This step is necessary to ensure that your computer can find the Java compiler and runtime environment. The environment variable "PATH" needs to be set to include the path to the bin directory of the JDK installation.
Compiling the Java program: Once you have written your Java code, you need to compile it using the Java compiler. The Java compiler will generate bytecode from your Java source code. The bytecode can then be executed on any system that has the Java Virtual Machine (JVM) installed.
Running the Java program: After compiling your Java code, you can run it using the Java Virtual Machine (JVM). You can use the command "java" followed by the name of your Java class file to run your program.
- //type on the source file "Example.java" below codes.
- class Example{
- public static void main(String[] args){
- System.out.println("Hello Java");
- }
- }
- //go to file and click save and close the file
- Example.java file to be compiled before the execution. compiling code is javac Example.java. type the code on cmd and press enter then you could see in your working directory file as an Example.class
0 Comments