Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Executing a Java Program

Tue Jan 27, 2009 10:59 am

Executing a Java Program :
Is it your first time to write code in Java.Suppose your wrote the following Java class and you want to run it .

Learn.java File
java code
package codemiles;

public class Learn {

String LessonTitle;
public Learn(String Title)
{
LessonTitle=Title;
}

public static void main(String[] args)
{

Learn myLesson=new Learn("Java Programming");
myLesson.printTitle();

}

public void setLeasonTitle(String LessonTitle) {
this.LessonTitle = LessonTitle;
}

public String getLessonTitle() {
return LessonTitle;
}
public void printTitle()
{
System.out.println("Lesson Title: "+LessonTitle);
}

}


The First case you will run it from the command line in your operating system . In Java the compiler compiles the code into a bytwcode which is not executable . Bytecode is somewhere in the middle of source code and executable code.

To create a bytecode :

Code:
javac Learn.java


After this step a bytecode will be generated as Learn.class .

To execute write :

Code:
java Learn


the output will be the following :
Code:
Lesson Title:  Java Programming




Post a reply
  Related Posts  to : Executing a Java Program
 java program     -  
 java program     -  
 java chat program.     -  
 email through JAVA program     -  
 compiling and getting of a java program     -  
 Elements of a Java Program     -  
 Need Java program for display the CPU usage     -  
 Java Chat Program between two computers     -  
 Java Program for communicate PC and Mobile     -  
 How can I call a C program in a Shell Script from Java     -  

Topic Tags

Java Basics