What is java?
Java is a programming language and a platform. Java is a high-level, robust, object-oriented, and secure programming language. It is a platform-independent language
Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, so James Gosling and his team changed the name from Oak to Java.
Why program in Java?
Java is easy to write and easy to run—this is the foundational strength of Java and why many developers program in it. When you write Java once, you can run it almost anywhere at any time.
Java can be used to create complete applications that can run on a single computer or be distributed across servers and clients in a network.
As a result, you can use it to easily build mobile applications or run on desktop applications that use different operating systems and servers, such as Linux or Windows
How to install java on your machine?
Step 1: Open https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html URL in the browser and it will navigate to the Amazon Corretto 17 download page from here you can download amazon correto JDK according to your system platform and architecture
what is amazon correto?
Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.
Step 2: After downloading Amazon Correto JDK you have to install it on your machine
Step 3: After installation, you have to verify the installation for that open command prompt and type in java -version, and hit enter then you will get this screen
when you download the JDK from the oracle website you have to set environment variables but with amazon correto you don't have to do that it will set everything automatically for you
So now you have successfully installed Java on your machine now you can write programs in any text editor and can run it in command prompt
Hello, World program:
so now we will write a program to print hello, world on our screen
step 1: Open any text editor and write this code on your text editor
public class HelloWorld {
public static void main(String []args)
{
System.out.println("Hello, world");
}
}
step 2: Save the file and always remember that the file name and the class name should be the same and the extension of the file should be .java for the above code the file name will be HelloWorld.java
step 3: Open the command prompt and navigate to the directory where you have saved your java program
step 4: Now type the commands in the command prompt as shown in the image below
Here javac is the java compiler when you will write javac HelloWorld.java in the command prompt and press enter then a new .class file will be generated in the same directory
Now write java HelloWorld in the command prompt and press enter it will show you the output in the next line as shown in the above image
Congratulations you have written your first java program
How does Codersarts help you in Java coding?
Codersarts provide :
Java assignment Help
Help in Java development Projects
Mentorship from Experts Live 1:1 session
Comments