This is the first tutorial I brought you to create your first java program "Hello Wolrd" as beginners. I will guide you step by step with illustration.
You can run any java program in following steps.
- JDK package is need to be installed to your pc. If you don't know or still didn't setup your jdk environment you can follow our previous tutorials.
- For ubuntu users see this tutorial or for windows users see this tutorial.
- Then next step is create the java program
- Compile and run the java program
Let's begin with introduction to a java code.
What is a class in java?
- Class is an essential part of a java code which is a template used to create objects. Simply java class is a set of objects. Object is an instant or an entity of a class. You will learn further abou an object from our next tutorial.
- Java files need to have at least one class defined in it. If there are multiple classes, then one class should have 'public' keyword.
- The name of the public class in a java file has to be the same name as java file.
What are the things java class contains?
- Member
- method
- constructor
- class
- interface
========================================================
class <className>{
className(){ // constructor created
}
public static void main(String[] args){ // main method
int a = 10;
className object = new className(); // object created
}
}
========================================================
Let's start creating your first java program
- You can write your code in any text editor or in an IDE like eclipse. I have used text editor in this tutorial.
- I am using nano text editor to write my java program. You may use gedit text editor too.
How to open a nano text editor?
- It is very easy to open nano text editor in ubuntu. First open the terminal and go to your path where you want to save your java file.
- Then type nano HelloWolrd.java in your terminal to open text editor. Then the nano is open in your terminal.
- Now you can write your code in the terminal.
- Or else you can use gedit editor.
- First go to the directory where you want to save your program using the temrinal and enter gedit HelloWorld.java in the terminal and press enter. Then the gedit editor will open.
- Don't forget to save your java file in ".java" extension ( Ex. HelloWorld.java ).
- Then type the following code in the java file you created.
================================================================
class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
}
================================================================
- Now compile this program by typing javac HelloWorld.java in the terminal.
- Then run the program by typing java HelloWorld
- So you can see the output in the terminal.
- This is java basic program and you can see the demo in following video.
If you cannot see this video you can watch it by clicking here.
Thank you very much for reading this tutorial. Our Next tutorial is about Java Variable and Data Types. If you have any problems regarding this tutorial feel free to make a comment below or you can contact us by sending email to this address, progtpoint@gmail.com.
That is the great one which I found on your website. Thank you so much for sharing this information.best of luck it was a good job.
ReplyDeletedigital marketing services in delhi
Supplements For Fitness inform you about health products and also plan a meal plan for you. Doing the right amount of exercise to lose weight works wonders for your weight management plan. There are many training modes you
ReplyDeletePremium Pure keto is a weight loss supplement. It is made by very unique formula of all natural ingredients. Now a day it is not difficult task to lose. More than around thousand of weight loss supplements are in market. These all supplements are helping you to lose your weight but the thing is that you have to select the best supplement which is pure naturally formulated and effective. Some of people are worried about their weight which is increasing day by day, and some of them may be worried for their skin disorders. Kindly Visit On Premium Pure keto Weight Loss Supplement
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis article is a great article that I have seen so far in my Java programming career, it will help a lot in setting up a new career for non experience developers.
ReplyDeletewebsite development company in Surat Gujarat
SAP HR Training In Noida
ReplyDeleteTutorial 2 in Java, the "Hello, World!" program, marks the exciting beginning of coding. Impact Net Neutrality This foundational lesson introduces essential syntax and structure, igniting the journey into Java programming.
ReplyDelete