Friday, June 6, 2014

MyEclipse - Create New Dynamic Web Project

---
MyEclipse - Create New Dynamic Web Project
STEPS
1) Run MyEclipse.
2) Create New Project.
Go to Menu File/New/Other…
3) Find a wizard for Dynamic Web Project.
4) Set Project Name, Target Runtime and Web module version.
5) Accept Default project build.        
6) Configure Web Module settings.
7) Project files and folder structure is created.
8) Create new Servlet for the project.
9) Type the Package Name and Class Name.
10) Take note of the Servlet/JSP Mapping URL. You will need it later.
11) Servlet (java class) is created.
12) Run the project.
13) Select target Server.
14) Welcome page is displayed in Web Browser.
15) Append the URL with the Mapping URL in shown in Step 10.
16) You can use POSTMAN REST CLIENT in Google Chrome to check the validity of the links.

1) Run MyEclipse.

2) Create New Project.

Go to Menu File/New/Other…

3) Find a wizard for Dynamic Web Project.

Type the word “dynamic”.
You should find “Dynamic Web Project”.
Click Next.

4) Set Project Name, Target Runtime and Web module version.

5) Accept Default project build.

6) Configure Web Module settings.

- Select Generate index.jsp welcome file.
- Generate web.xml deployment descriptor.
Click Finish.

7) Project files and folder structure is created.

8) Create new Servlet for the project.

Right-click the project name, select New/Servlet.

9) Type the Package Name and Class Name.

Click Next.

10) Take note of the Servlet/JSP Mapping URL. You will need it later.

11) Servlet (java class) is created.

12) Run the project.

13) Select target Server.

14) Welcome page is displayed in Web Browser.

15) Append the URL with the Mapping URL in shown in Step 10.

16) You can use POSTMAN REST CLIENT in Google Chrome to check the validity of the links.

---

Monday, June 2, 2014

How To Install IBM WebSphere 6-1 Application Server

---
How To Install IBM WebSphere 6.1 Application Server

STEPS

1) Get Installation Files.

2) Select WebSphere Application Server Installation.

Click Launch the installation wizard for WebSphere Application Server for Developers.

3) Wait for InstallShield Wizard to run.

https://lh3.googleusercontent.com/ofcoPVt0BsUbakRLbdL36gZKvtgfL7zlWldlx4Fdvk-WWwcjrLQVDu7mkZGm0DIJM_yh7R3_bcPvE35Bb2LO2BDPfoIgBmTpOf2kzd4jU5VQx8jMhsFOmn753YiM2HeueC73oFw81Z8

4) Start the Installation Wizard.

5) Agree to terms.

6) Check pre-requisites.

7) Select Install Sample Applications.

        

8) Set Installation Directory.

9) Set admin and samples password.

e.g password

10) Review Installation Summary.

11) Installation Starts.

12) Installation completed.

13) Installation verification.

14) First Steps Output.

You may get a text output as follows:
Server name is:server1
Profile name is:AppSrv01
Profile home is:C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01
Profile type is:default
Cell name is:notarazipcNode01Cell
Node name is:notarazipcNode01
Current encoding is:Cp1252
Server port number is:9080
IVTL0020I: The Installation Verification Tool cannot connect to WebSphere Application Server; waiting for the server to start.
IVTL0010I: Connecting to the WebSphere Application Server notarazipc on port: 9080
IVTL0020I: The Installation Verification Tool cannot connect to WebSphere Application Server; waiting for the server to start.
Start running the following command:cmd.exe /c "C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\bin\startServer.bat" server1 -profileName AppSrv01
>ADMU0116I: Tool information is being logged in file C:\Program
>           Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\startServer.log
>ADMU7701I: Because server1 is registered to run as a Windows Service, the
>           request to start this server will be completed by starting the
>           associated Windows Service.
>ADMU0116I: Tool information is being logged in file C:\Program
>
>           Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\startServer.log
>
>ADMU0128I: Starting tool with the AppSrv01 profile
>
>ADMU3100I: Reading configuration for server: server1
>
>ADMU3200I: Server launched. Waiting for initialization status.
>
>ADMU3000I: Server server1 open for e-business; process id is 1192
>
IVTL0015I: WebSphere Application Server notarazipc is running on port: 9080 for profile AppSrv01
Testing server using the following URL:http://notarazipc:9080/ivt/ivtserver?parm2=ivtservlet
IVTL0050I: Servlet engine verification status: Passed
Testing server using the following URL:http://notarazipc:9080/ivt/ivtserver?parm2=ivtAddition.jsp
IVTL0055I: JavaServer Pages files verification status: Passed
Testing server using the following URL:http://notarazipc:9080/ivt/ivtserver?parm2=ivtejb
IVTL0060I: Enterprise bean verification status: Passed
IVTL0035I: The Installation Verification Tool is scanning the file C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\SystemOut.log for errors and warnings.
[6/3/14 1:01:46:322 SGT] 0000000a WSKeyStore    W   CWPKI0041W: One or more key stores are using the default password.
[6/3/14 1:02:05:289 SGT] 0000000a ThreadPoolMgr W   WSVR0626W: The ThreadPool setting on the ObjectRequestBroker service is deprecated.
IVTL0040I: 2 errors/warnings are detected in the file C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\SystemOut.log
IVTL0070I: The Installation Verification Tool verification succeeded.
IVTL0080I: The installation verification is complete.

15) Administer Server.

16) Check the pre-installed Application.

17) Browse the Samples Gallery.

---

Sunday, June 1, 2014

IDEONE Java Basics 108 – Class and Object

---
Java Basics 108 – Class and Object

PREREQUISITE

This tutorial uses the online compiler IDEone (www.ideone.com ).
IDEone gives you few benefits:
1) Zero setup. You just need Internet Connection and a modern Web Browser.
2) Online storage. You can refer back to the codes at later time.
3) Public codes available. You can also see how others write codes and learn from them as well.
4) Online Learning. You can ask a companion at remote location to help edit the codes or review your codes for improvements or troubleshooting algorithms.

STEPS

1) Start with the basic template

Clone the code above. (Click the Fork button).

2) Create Java Class

2-1) Declare a class ExamDetails

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                // your code goes here
        }
}
2-2) Add second class StudentResults

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                // your code goes here
        }
}
class StudentResults {
}
2-3) Add properties to the StudentResults class.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                // your code goes here
        }
}
class StudentResults {
        String Full_Name;
        String Exam_Name;
        String Exam_Score;
        String Exam_Grade;
}
2-4) Declare a StudentResult object called aStudent

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
        }
}
class StudentResults {
        String Full_Name;
        String Exam_Name;
        String Exam_Score;
        String Exam_Grade;
}
2-5) Assign property value to aStudent
Try printing the value.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                aStudent.Exam_Name="VB.NET";
                String exam=aStudent.Exam_Name;
                System.out.println(exam);
        }
}
class StudentResults {
        String Full_Name;
        String Exam_Name;
        String Exam_Score;
        String Exam_Grade;
}
2-6) Change access to class property in StudentResults.
Try running the code.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                aStudent.Exam_Name="VB.NET";
                String exam=aStudent.Exam_Name;
                System.out.println(exam);
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
}
At this point, the compiler will output error message:

Main.java:13: error: Exam_Name has private access in StudentResults
               aStudent.Exam_Name="VB.NET";
                       ^
Main.java:14: error: Exam_Name has private access in StudentResults
               String exam=aStudent.Exam_Name;
                                   ^
2 errors
Comment (//) those lines that have got errors.
2-7) Add an initiating method (Constructor ) to StudentResults.
a) The name of the method is similar to the name of the class.
b) The parameters of the method are assigned to the property of the class.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                //aStudent.Exam_Name="VB.NET";
                //String exam=aStudent.Exam_Name;
                //System.out.println(exam);
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
        StudentResults (String name, String grade){
                Full_Name=name;
                Exam_Grade=grade;
        }
}
At this point, if you try to compile, you may get errors because the new object declaration parameter doesn’t  match with the constructor parameter declaration.

Main.java:12: error: constructor StudentResults in class StudentResults cannot be applied to given types;
                StudentResults astudent= new StudentResults();
                                         ^
 required: String,String
 found: no arguments
 reason: actual and formal argument lists differ in length
2-8) Change the constructor declaration.
a) Omitting parameter
b) Assigning default values to all class properties.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                //aStudent.Exam_Name="VB.NET";
                //String exam=aStudent.Exam_Name;
                //System.out.println(exam);
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
        StudentResults (){
                Full_Name="No name given";
                Exam_Name="Unknown";
                Exam_Score="No Score";
                Exam_Grade="Unknown";
        }
}
Note: delete the statement marked with “//”
2-9) Create method to change class property.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
        StudentResults (){
                Full_Name="No name given";
                Exam_Name="Unknown";
                Exam_Score="No Score";
                Exam_Grade="Unknown";
        }
        String fullName (String aName){
                Full_Name=aName;
                return Full_Name;
        }
}
2-10) Edit the main method.
a) Add a call to class method.
b) Add an output statement to print the class property value.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                String sName = aStudent.fullName("Bill Gates");
                System.out.println( sName );
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
        StudentResults (){
                Full_Name="No name given";
                Exam_Name="Unknown";
                Exam_Score="No Score";
                Exam_Grade="Unknown";
        }
        String fullName (String aName){
                Full_Name=aName;
                return Full_Name;
        }
}
2-11) Add another method to class StudentResults

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                String sName = aStudent.fullName("Bill Gates");
                System.out.println( sName );
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
        StudentResults (){
                Full_Name="No name given";
                Exam_Name="Unknown";
                Exam_Score="No Score";
                Exam_Grade="Unknown";
        }
        String examName(String examCode){
                if (examCode.equals("VB")){
                        Exam_Name="Visual Basic.NET";
                }
                else if (examCode.equals("JV")){
                        Exam_Name="Java";
                }
                else if (examCode.equals("C#")){
                        Exam_Name="C# .NET";
                }
                else if (examCode.equals("PH")){
                        Exam_Name="PHP";
                }
                else {
                        Exam_Name="No Exam Selected";
                }
                return Exam_Name;
        }
}
2-12) Edit main method
a) Add a call to the new class method.
b) Add an output statement to print the returning value.

/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class ExamDetails
{
        public static void main (String[] args) throws java.lang.Exception
        {
                StudentResults aStudent= new StudentResults();
                String sName = aStudent.fullName("Bill Gates");
                String exam = aStudent.examName("VB");
                System.out.println( sName );
                System.out.println( exam );
        }
}
class StudentResults {
        private String Full_Name;
        private String Exam_Name;
        private String Exam_Score;
        private String Exam_Grade;
        StudentResults (){
                Full_Name="No name given";
                Exam_Name="Unknown";
                Exam_Score="No Score";
                Exam_Grade="Unknown";
        }
        String examName(String examCode){
                if (examCode.equals("VB")){
                        Exam_Name="Visual Basic.NET";
                }
                else if (examCode.equals("JV")){
                        Exam_Name="Java";
                }
                else if (examCode.equals("C#")){
                        Exam_Name="C# .NET";
                }
                else if (examCode.equals("PH")){
                        Exam_Name="PHP";
                }
                else {
                        Exam_Name="No Exam Selected";
                }
                return Exam_Name;
        }
}
3) More Class Methods

REFERENCE

---