Online Tutorial for Java beginners to learn basic concepts of Core Java. I have divided this tutorial into three sections. First you will learn the fundamentals of. Getting started with Java. Here we will discuss some basics topics related to Java.
Where to download Java. How to install Java. Setting up the Environment Variables. Our First Java Program. How to compile a Java application. How to run a Java Application. Difference between important terms in Java (JDK vs JRE or J2. SE vs J2. EE.). How to Download Java. Latest version of Java can be downloaded from Java Website. Java Installation. There are no special requirements when installing Java. Be sure that you have suitable permissions on your computer to install software. It can be installed like any other software (. Setting up the Environment Variables. After installing Java there are some environment variables that need to be set. CLASSPATH : This environment variable points to the location of JDK home directory. It also contains the address of folder from where jars get loaded by Class. Loader (For more details of Class. Loader visit here)JAVA_HOME : This environment variable will point to the location of Java home directory. How to set environment variable in different platforms. Windows XPTo set up environment variables in Windows XP right click on the “My Computer” icon and select Properties. In the Property window select the “ADVANCED” tab and click on “ENVIRONMENT VARIABLES” . A window will appear were you can enter a new environment variable under System Variables by selecting New button. Windows Vista / 7. To set up environment variables in Windows Vista / 7 right click on “Computer” and select Properties. In Property window select “ADVANCED SYSTEM SETTINGS” and then select “ADVANCED” tab and click “ENVIRONMENT VARIABLES”. A window will appear were you can enter new environment variable under User/System Variables by selecting New button. How to Check if Java is Installed. To check if your Java is installed properly open Command Prompt . To open command prompt write “CMD” in run command and hit enter. In the command prompt window write “java - version“. If your Java is installed properly and all environment variables are configured correctly it will show the version of Java installed . Information reflected on the command prompt will be like. C: \Users\Jbt> java - version. Java(TM) SE Runtime Environment (build 1. Java Hot. Spot(TM) Client VM (build 2. If there is any problem while installing or in setting up the environment variable, output on command prompt will be as shown below.'java' is not recognized as an internal or external command. How to check if Java is up to date. To know if the Java installed on your system is up to date Click Here. Our First Java Program. Though the popular first program to write in Java is” Hello World !! Hello JBT !! “. ?Open any editor and write the below code. First. Programme {. String args[]) {. System. out. println("Hello JBT!"). Save the file with the name “First. Programme. java” in folder “c: \jbt”. Please note that name of the file should be same as the name given to public class(For more details regarding class file rules click here). Once the file is saved, open the command prompt and change the working directory to “c: \jbt”, where your file is saved. Write “javac First. Programme. java to compile the Java code as below. C: \Users\JBT> cd C: JBT. C: JBT> javac First. Programme. java. C: JBT> If the java file is compiled properly the compiler will create a class file for the source. Java. It will be saved in the same location as the source file. Since no package is declared in the given code the . Notice the difference for Java files using package declaration. Let’s create another Java file as below. First. Programme. With. Package {. public static void main(String args[]) {. System. out. println("Hello JBT!"). Save this file as “First. Programme. With. Package. Now go to the command prompt and execute the below command. First. Programme. With. Package. java. It will create the class file in a corresponding package(com. Now that you know how to compile Java file with package and without package, the next step would be run these class files. How to Run Java Application. Now that your Java file is compiled we can execute the application using the “java” command as below. Without Package. C: \JBT> java First. Programme. C: \JBT> With Package. C: \JBT> java com. First. Programme. With. Package. Hello JBT! Or. C: \JBT> java com/jbt/First. Programme. With. Package. Note*: The “java” command uses the class file name without its extension(. With this we are done creating and running our very first Java application. In the next section we will learn the difference between JDK and JRE. Series Navigationjdk vs jre vs jvm > >.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |