Wednesday, April 28, 2010

Java and JDeveloper Learnings

After a LOOOONG break, I am starting again in Java programming with JDeveloper.

Here are some fresh learnings-

1. Using JDeveloper beginner- Great video-
http://jdeveloperzerotopro.com/

2. How to enable input from the keyboard in Jdeveloper-
  1. Go to project properties(Right Click on the Project),
  2. click on Run/Debug settings,
  3. select your Run configuration (Default) and Click Edit.
  4. Locate "Tool settings" and check "Allow program input" in Additional Runner Options.
  5. Save settings and run your program again.
  6. Now you will see under the console input field for your inputs.
JDeveloper follows [Application --> Project --> Java Src file] architecture.

On a Java src file, first --> Make and then --> Run.

My first program- tried first on Console & then on JDeveloper-

________________________________________
package learnjavaproject;

public class Learn1 {
public Learn1() {
super();
}
public static void main (String [] args){
System.out.println("hello");
}
}
________________________________________

Then am working now on an App - "PayRoll"

These are the specs of this App-

Base class - Employee. [Properties - First Name, Last name, Base Salary ]

Three extended classes- Software Engineer, Project Leader, Project manager.

Factors affecting salary of these employees-
Software Engineer - skill
Project Leader - No_Team_Members
Project_manager
Project manager

________________________________________
Expected behavior --> By giving a type of employee and the parameter, the salary should be given back.
________________________________________


Employee Class-->
________________________________________

package learnjavaproject;// Project name is LearnJavaProject.

public class Employee {
private String FirstName;
private String LastName;

public Employee() {
super();
}
public Employee(String FirstName, String LastName){
SetFirstName(FirstName);
SetFirstName(LastName);
}
public void SetFirstName(String FirstName){
this.FirstName = FirstName;
}
public void SetLastName(String LastName){
this.LastName = LastName;
}
public String GetFirstName(){
return FirstName;
}
public String GetLastName(){
return LastName;
}
public String FullName(){
return FirstName +" "+LastName;
}
}
________________________________________

And the driver file -

package learnjavaproject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import learnjavaproject.Employee;


public class PayRoll {
public PayRoll() {
super();
}
public static void main (String [] args) throws Exception{
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));

String FirstName;
String LastName;

System.out.println("Enter First name: ");
String fName = br.readLine();
System.out.println("Enter last name: ");
String lName = br.readLine();

Employee e = new Employee(fName,lName);
System.out.println(e.GetFirstName());
}
}

________________________________________

But the output is null at this time. Let me try to debug this.. Will write again later...:)

Oh , It was a case Sensitive issue. I had put Firstname instead of FirstName...... OMG, what !!!!!
Now it works, Thanks to Anna who trouble-shooted this.