Path Setup
1. Open This PC (My Computer)
2. Right click on anywhere on blank
area. (not or
any drive or any other icon) then click on properties
java path seting
3. Click on Advanced System Setting (Left side on screen).
javapath seting in windows 10 |
4. Environment Variable
java path seting |
5. Click on new on user variable (upper section). Then type “path” in variable name and “C:\Program Files\Java\jdk1.8.0_144\bin” in variable value. Then click on ok.
java path |
6. Click on ok then again ok.
Check installation and path setup-Open command prompt (cmd) and check path variable is
successfully set or not.
1.
Search for cmd
on start button and click on it.
java pathseting in cmd |
2.
Type “javac” in command prompt then hit enter.
java path cmd |
Note-If
“javac” is recognized in your cmd it means installation and path variable setup
process successful and you will get output like above screenshot else process
failed you need to check your mistake.
How to create ,save, compile and run java program-
1.
Type the
following code in notepad or notepad++.
class Demo
{
public static void
main(string agrs[])
{
System.out.println(“Hello
java”);
}
2.
Press Control +
S to save the program.
3.
Select the
location where you want to save the program and . Type file name “Demo.java” is
name section then select All type in save as type click on save.
4.
Type “cmd” then
hit Enter button in address bar of same location you have saved your java
program to open command prompt in the location.
varible seting |
5.
Type “javac
Demo.java” in cmd then hit enter to
compile program (javac is a command that is used to compile java file and
Demo.java is name of current java program file).
6.
Type “Java
Demo”(java is command that is used to run java bytecode and Demo is main class
name is current program.)
java path seting in CMD. |
System.out.println():-
This
statement is used to print text on the screen as output, where system is a
predefined class, and out is an object of the PrintWriter class defined in the
system. The method prints the text on the screen with a new line.
Comments in Java:-
Single
Line-//……
Multi
Line-/*…………………………………*/
Naming Conventions-
1.
Variable names
can begin with a letter, underscore, currency character.
Ex-age, name, _address, emp1_Add, etc.
2.
Constant
variable should be written using all capital letters.
Ex-MAX, VALUEetc.
3.
Each word of
class name and interface name start with a capital letter.
String, StringBuffer, DataInputStream etc.
4.
Method name
start with a small letter, then each word start with capital letter.
Ex-Println(),
readLine(), getChars() etc.
5.
Package nae in
java are written in small letter.
Ex-java.io;
No comments:
Post a Comment