You can create your java program using command prompt or Using JDeveloper. Let us discuss about both ways to create the java program.
1)My First Java program using JDeveloper:
Step 1: Open JDeveloper and create your own application
Right click on Applications->New

Select category as General and Items as Application

Name your application

Name your project name

Step 2: Create your Java program
Expand your application from applications Navigator and right click on your project >>New

Select category as General and Items as Java class

Name your class and select check box Generate mail method

Step 3: Execute your java program
Write the output statement in the program

Right click and Rebuild the program. Right click and Run the program. You can get the output at the bottom

2)My First Java program using Command Prompt:
Step 1: Create your java program in notepad and save the file with extention *.java
Step 2: Need to set java path
If your *.java file is saved outside the JDK/bin folder you need to set java path.
There are 2 ways i.e Temporary and permanent
How to set temporary path:
1)Go to command prompt and go to the location where the *.java file is placed.

2)Find the JDK/bin path and execute that in command prompt
set path= C:\Program Files\Java\jdk1.6.0_35\bin

How to set permanent path:
Go to MyComputer properties -> advanced System settings -> environment variables -> new tab of user variable -> write ‘path’ in variable name -> write path of bin folder in variable value -> ok -> ok -> ok

Step 3:Compile the *.java file using the command ‘javac file_name.java’ in command prompt
Here *.class file will be created in the folder where you are in
Step 4: Execute the *.java file using the command ‘java file_name’
Please find the output of myFirstProg

No comments:
Post a Comment