Nad Installation Docs-Amit

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 79

Now it’s time to start writing java programs.

Before writing a java program you have to make sure


all the below necessary resources installed on your machine.

1. JDK software installation and setting classpath.


2. Eclipse IDE
3. MySQL Database
4. Tomcat Server

1. Installation of JDK software:

Install the JDK if you don't have installed it, download the JDK and install it.
Steps How to install the steps:

1) From this link you can download latest version of java or you can download previous
versions of java according to your requirement.
2) Click on JDK button.
Accept the license agreement and click on download link based on your bit operating machine (32
bit or 64 bit).

Click on this link if your machine is 64


bit otherwise select the link for 32
3)
bit.
Here you can close the installation otherwise if you need API Documentation then click on next steps.

Click on close button and you are done with the java installation.
After this you have to set the class path of the java. So, that you can store and run your programs
from any of the drive/folder.

How to set path in JAVA:

The path is required to be set for using tools such as javac, java etc.

If you are saving the java source file inside the jdk/bin directory, path is not required to be set
because all the tools will be available in the current directory.

But if you are having your java file outside the jdk/bin folder, it is necessary to set path of JDK.

There are 2 ways to set java path:

1. temporary
2. permanent

1) How to set Temporary Path of JDK in Windows

To set the temporary path of JDK, you need to follow following steps:

 Open command prompt


 copy the path of jdk/bin directory
 write in command prompt: set path=copied_path

For Example:
set path=C:\Program Files\Java\jdk1.6.0_23\bin

Let's see it in the figure given below:


2) How to set Permanent Path of JDK in Windows

For setting the permanent path of JDK, you need to follow these steps:

 Go to MyComputer properties -> advanced tab -> environment variables -> new tab of
user variable -> write path in variable name -> write path of bin folder in variable value
-> ok -> ok -> ok

For Example:
1)right click on MyComputer properties

2)click on advanced tab


3)click on environment variables
4)click on new tab of user variables
5)write path in variable name and
Copy the path of bin folder

C:\Program Files\Java\jdk1.8.0_73\bin
)click on ok button

9)click on ok button
Now your permanent path is set. You can now execute any program of java from any drive.

10) click on ok button


11)click on ok button

Now your permanent path is set.You can now execute any program of java from any drive.
2. Eclipse IDE Installation :

In the previous, we saw download and installation of the jdk. For writing the java program you
need an editor that can be anything like notepad, eclipse IDE, Netbeans IDE. All of them are using
IDE so that it provide complete resources needed for writing, compiling, running and displaying
the output at one place. You no need to switch your tabs for these things.

 First you download the eclipse IDE. https://eclipse.org/downloads/


The above link will download the latest version of the eclipse IDE.
 If you want to download the older versions then click the following the link and download as
per your requirement http://www.eclipse.org/downloads/packages/eclipse-ide-java-
developers/junor

 Select Eclipse IDE for java EE developers and you can download either 32 bit or 64 bit
according to your machine.

Note: By default the downloaded file is a .zip file.

 Extract / unzip the downloaded file to any folder of your choice. It is better to select C:/ as the
folder.
 When eclipse starts up for the first time it prompts you for the location of the workspace
folder. All your data will be stored in the workspace folder. You can accept the default or
choose a new location.

If you select "Use this as the default and do not ask again", this dialog box will not come up again.
You can change this preference using the Workspaces Preferences.

 After selecting the path click ‘ok ‘button.


 Click on workbench on top right corner.
 It will open eclipse IDE window.

A perspective has only one editor area in which multiple editors can be open. The editor area is
usually surrounded by multiple views. In general, editors are used to edit the project data and views
are used to view the project metadata. For example the package explorer shows the java files in the
project and the java editor is used to edit a java file.

The eclipse window can contain multiple editors and views but only one of them is active any given
point of time. The title bar of the active editor or view looks different from all the others.

Explore Menus
The typical menus available on the menu bar of an eclipse window are:
 File: The File menu allows you to open files for editing, close editors, save editor content and
rename files. Among the other things, it also allows you to import and export workspace content
and shutdown Eclipse.
 Edit: The Edit menu presents items like copy & paste.
 Navigate: The Navigate menu allows you to quickly locate resources and navigate to them.
 Search: The Search menu presents items that allow you to search the workspace for files that
contain specific data.
 Project:The menu items related to building a project can be found on the Project menu.
 Run:The menu items on the Run menu allow you to start a program in the run mode or debug
mode. It also allows presents menu items that allow you to debug the code.
 Window:The Window menu allows you to open and close views and perspectives. It also allows
you to bring up the Preferences dialog.
 Help:The Help menu can be used to bring up the Help window, Eclipse Marketplace view or Install
new plug-ins. The about Eclipse menu item gives you version information.

Explore Views
Eclipse views allow users to see a graphical representation of project metadata. For example the
project navigator view presents a graphical representation of the folders and files associated with a
project and properties view presents a graphical representation of an element selected in another
view or editor.
An eclipse perspective can show any number of views and editors. All editor instances appear in a
single editor area whereas views are placed inside view folders. A workbench window can display any
number of view folders. Each view folder can display one or more views.

The following picture shows four views arranged in a view folder.

Opening a view:
To open a view click on the Window menu and select the Show View menu item and either the menu
item that represents a view or the Other menu item.
Clicking on the Other menu item brings up the Show View dialog box that allows you to locate and
activate a view.

The views are organized by category. To quickly locate a view just type the name of a view into the
filter text box. To open a view, select it and click on the OK button.
Perspective
An eclipse perspective is the name given to an initial collection and arrangement of views and an
editor area. The default perspective is called java. An eclipse window can have multiple perspectives
open in it but only one perspective is active at any point of time. A user can switch between open
perspectives or open a new perspective. The active perspective controls what appears in some menus
and tool bars.
Open Perspective:
To open a new perspective, click on theWindowsOpen PerspectiveOther.The Open Perspective
dialog box shows all the available perspectives.

Switching between perspectives:


The most commonly used perspectives for java development are the Java perspective and Debug
perspective. Users can switch between open perspectives by clicking on the Perspective name on the
toolbar.

Closing Perspective:
To close a perspective, right click on the perspective name in toolbar and select the Close menu item.

Workspace
The eclipse workspace contains resources such as:
 Projects
 Files
 Folders
The workspace has a hierarchical structure. Projects are at the top level of the hierarchy and inside
them you can have files and folders. Plug-ins use an API provided by the resources plug-in to manage
the resources in the workspace.
UI Elements for Managing the Workspace:
Users use the functionality provided by views, editors and wizard to create and manage resources in
the workspace. One among the many views that show the content of the workspace is the Project
Explorer view.

The File Wizard (FileNewFolder) can be used to create a new folder.

The File Wizard (FileNewFile) can be used to create a new file.

1. Create Java Project


Click on File menu  choose NewJava ProjectEnter Project NameNextFinish
After Creation of new Project, you can see the project structure in Package Explorer as below figure

2. Create new Java Package


Right click on Project choose Newchoose Package Select the Source folder and, Enter Package
NameFinish

The package explorer will show the newly created package under the source folder.

3. Create new Java Class


Opening the New Java Class wizard:
You can use the New Java Class wizard to create a Java class. The Java Class wizard can be invoked in
different ways:
 By clicking on the File menu and selecting NewClass
 By right clicking in the package explorer and selecting New > Class
 By clicking on the class drop down button (  ) and selecting class (  )
Before bringing up the New Java Class wizard, if possible, select the package in which the class is to be
created so that the wizard can automatically fill in the package name for you.
Using the New Java Class wizard:
Once the java class wizard comes up:
 Ensure the source folder and package are correct
 Enter the class name
 Select the appropriate class modifier
 Enter the super class name or click on the Browse button to search for an existing class
 Click on the Add button to select the interfaces implemented by this class
 Examine and modify the check boxes related to method stubs and comments
 Click on Finish

The newly created class should appear in the Package Explorer view and a java editor instance that
allows you to modify the new class should appear in the editor area.

4. Java Build Path


Setting the Java Build Path
The Java build path is used while compiling a Java project to discover dependent classes. It is made up
of the following items:
 Code in the source folders
 Jars and classes folder associated with the project
 Classes and libraries exported by projects referenced by this project

The java build path can be seen and modified by using the Java Build Path page of the Java Project
properties dialog.

To bring up the Java Project properties dialog box, right click on a Java Project in the Package Explorer
view and select the Properties menu item. On the left hand side tree select Java Build Path.
A common requirement seen while developing java applications is to add existing jars to the java
build path. This can be accomplished using the Libraries tab. In the Libraries tab, just click on Add JARs
if the jar is already in the Eclipse workspace or click on Add External JARs if the jar is elsewhere in the
file system.

5. Run Java Class


The Java Class can be run in multiple ways. Some of them listed below.
1. The quickest way to run a Java program is to using the Package Explorer view.
In the Package Explorer view:
Right click on the Java Class that contains the main () method  Select Run asJava
Application.
2. The same action can be performed using the Package Explorer view by selecting the class that
contains the main method and pressing Alt + Shift + X, J
3. Open java file (must contain main method) in editor. Right click on editor  Select Run as
Select Java Application.
Example:
1. Open HelloWorld.java file
2. Edit HelloWord.java file as below
packagecom.demo;

publicclass HelloWorld {
publicstaticvoid main(String args[]){
System.out.println("Hello World!");
}
}
3. Right click on HelloWorld.java Select Run asJava Application.

4. Finally you should see the output in Console View as below

6. Create JAR File


Opening the Jar File wizard:
The Jar File wizard can be used to export the content of a project into a jar file.
To bring up the Jar File wizard:
 In the Package Explorer select the items that you want to export. If you want to export all the
classes and resources in the project just select the project.
 Click on the File menu and select Export.
 In the filter text box of the first page of the export wizard type in "JAR".
 Under the Java category select JAR file
 Click on Next

Using the JAR File wizard:


In the JAR File Specification page:
 Enter the JAR file name and folder
 The default is to export only the classes. To also export the source code Click on the "Export
Java source files and resources" check box.
 Click on Next to change the JAR packaging options
 Click on Next to change the JAR Manifest specification
 Click on Finish
7. Build Project
A project can have zero or more builders associated with it. A java project is associated with a java
builder. To see the builders associated with a project:
 In the Package Explorer view right click on the project and select Properties
 On the tree in the left hand side click Builders
It's the java builder that distinguishes a Java project from other types of projects. By click on the New
button you can associate the Ant builder with a java project.
The java builder is responsible for compiling the java source code and generating classes. The java
builder is notified of changes to the resources in a workspace and can automatically compile java
code.

To disable automatic compilation deselect the Build Automatically option from the Project menu.

If automatic compilation is disabled then you can explicitly build a project by selecting the Build
Project menu item on the Project menu. The Build Project menu item is disabled if the Build
Automatically menu item is selected.

Extract source from the TTD folder.

3. MySQL Installation :

http://dev.mysql.com/downloads/mysql/
Click on download button for downloading.

For offline installation click on download which is having large size.


For Online installation you can click on smaller size download button.

Here am downloading the offline installation.

Click on No thanks, just start my download


It starts downloading your file.

For the older versions of MySQL,

http://dev.mysql.com/downloads/mysql/
Click on the Archived versions

Select the products which ever you need, here am selecting the MySQL community server.

Pick the version number for MySQL Community Server you want and, as exactly as possible, the platform
you want.

Installing MySQL on Linux/Unix:

Refer from http://www.tutorialspoint.com/mysql/mysql-installation.htm


Installing MySQL on Windows:

Download MySQL Community edition at http://dev.mysql.com/downloads/installer/. It installs


thecommunity edition of all MySQL products.

Video: https://www.youtube.com/watch?v=UgHRay7gN1g

Refer from http://dev.mysql.com/doc/refman/5.7/en/mysql-installer-gui.html

Once download your file (msi installer), double click on that file for installing

Click on Run button.


Check the box I accept the terms and conditions and Click on Next Button.

In this step, choose the setup type you want and click on Next button.
Right now we need for development purpose so select Developer Default anc Click on Next Button.
Click on Next Button.
These are the products will install once we Click on Execute Button.
It will start installing all the products. Once installing all the products Click on Next Button.
Click on Next Button.
Click on Next Button.
Click on Next Button.
Creating accounts and roles.
Create new password, here you can create new user accounts and can give privileges

Click on Next Button.


Click on Next Button.
Click on Execute Button.
Once applying configuaration is done then click on Finish button.
Click on Next Button for product configuration.

Click on Check button for testing the server whether it is connected successfully or not.

Click on Next Button.


Click on Execute button for applying server configuration.
Once the server configuration is done, click on Finish button.

It shows the below screen.


Click on Next Button.
This screen shows the Installation Complete.

If you want to start MySQL workbench right away then check the box otherwise you can start workbench
later.

Click on Finish Button.

Once installation is successful then you can start working either from workbench or MySQL command
client.

Connect to MySQL Server:


1. Using MySQL Command Line Client:

Open MySQL Command Line Client application, and it will ask for admin password. Enter the password
and click enter button.
If password is correct, you should see as below

Now you can perform operations like create database, tables, and insert data into tables, updating table
by using sql commands.
Database and table creation:-

we are creating a database called twdemo and then creating associated tables. To create the database, allow
the database to be used and create a table, implementing the following commands:

mysql> CREATE DATABASE twdemo;

mysql> USE twdemo;


mysql> CREATE TABLE thingworx (StringField varchar(100),NumberField int(15),BooleanField
tinyint(1),DateField date);

mysql> DESC thingworx;


Inserting the values in table:-
The INSERT INTO statement is used to add values to a table. Appearing here is the command to insert 5
student records into the table 'Information:'
INSERT INTO thingworx VALUES ('movies',20,1,'2017-03-20');
INSERT INTO thingworx VALUES ('Update Test',56,1,'2017-03-15');

Viewing the table record:-


Now that you're done inserting values, how do you check to see if the records are in the table now? This is
done with the SELECT command, which you can see play out here:
mysql> SELECT * FROM thingworx;
Updating the selected record:-
To update information in a specific column for a specific record, the UPDATE command is used as follows:
mysql> UPDATE thingworx SET DateField = '2019-03-15' WHERE StringField = "Update Test";
This updates the dob of the record whose last name is Wills and returns the result.
The SQL DELETE command is used to delete rows that are no longer required from the
database tables;  

mysql>;DELETE FROM thingworx WHERE StringField = "Update Test";

Here you will find a collection of basic MySQL statements that should prove useful for basic CRUDS operations (create, replace,
update, delete, select).

There may be some issues with the kind of quotes you use around your data. If you are having difficulties, try using singe quotes
(‘  ) or tricky quotes (  `  -- on keyboard key next to number 1) around your data. One or the other is bound to work.

The following statements are covered in this page:

Please refer this link for basic MySQL commands


https://www3.ntu.edu.sg/home/ehchua/programming/sql/MySQL_Beginner.html

Screens will update later - under construction

2. Using MySQL Workbench:

MySQL Workbench is a unified visual tool for database architects, developers, and DBAs. MySQL
Workbench provides data modelling, SQL development, and comprehensive administration tools for
server configuration, user administration, backup, and much more.

GoTO Start button - All Programs MySQL-click on MySQL workbench.


To add a new connection, click on [+] icon to the right of the MySQL Connections title on the Home
Screen.

This will open the Setup New Connection as shown in the below figure
Fill out the connection details. You can test the connection also by entering the password.

If the connection is successful then below screen will appear and Click on Ok Button.
Click on OK Button and you connection is ready appear on the workbench.

Now you can start writing the MySQL commands in your particular connection. Like that you can create
number of connections.
Click on the connection and database window is opened.
Now first create the database. Click on the button which shows on the below screen.

Write the database name in the Name field and Click on Apply button.
Note : lowercase letters are accepted.
Click on Apply Button.
Click on Finish Button.
Creating tables in the database.
For creating, inserting, update, alter and other operations you can use either SQL editor or schema.
Click on SQL Editor which is shown in the below screen.

It will open SQL Editor in below screen and you can start writing the MySQL commands and execute.

Write the MySQL command, execute and displaying the output which is shown in below screen.
MySQL tutorial - Under Construction

4. Tomcat server Installation :

Download & Install:

You can download the file either in .zip file or windows service installer file.
 Download latest version of tomcat server file (.zip) from
https://tomcat.apache.org/download-70.cgi
Unzip the download file in your desired folder (ex: C:\apache-tomcat-7.0.65)

Tomcat Manager:
Tomcat manager application is provided as part of the Tomcat distribution and is stored in
the CATALINA_HOME/webapps/manager  directory by default. It’s a special web application that
allows manage other web applications while the Tomcat server is running. One can, for example, deploy,
undeploy, start, and stop web applications on the server using this tool.
By default, access to the manager application is disabled; this can be accessed only by an authenticated
user. The default realm for the manager application is  CATALINA_HOME/conf/tomcat-
users.xml .
To set up the manager application, add a user with the manager role to this file. The role manager names
can be found in the  CATALINA_HOME/webapps/manager/WEB-INF/web.xml  file of the Manager
Web application. One of the available roles is  manager-gui  – provides access to the HTML interface.
Add / update users and roles in tomcat-users.xml:
1. Open CATALINA_HOME/conf/tomcat-users.xml
2. Add the manager role and then alter an existing user (such as tomcat), as follows:
<?xmlversion='1.0'encoding='utf-8'?>
<tomcat-users>
<rolerolename="tomcat"/>
<rolerolename="admin-gui"/>
<rolerolename="manager-gui"/>
<userusername="tomcat"password="tomcat"roles="tomcat, manager-
gui,admin-gui"/>
</tomcat-users>

Note: whenever you make changes in any .xml files of tomcat, must need to stop and start
the server for reflecting the changes.
Access Manager Application:
1. Start Server(refer 15.3 step)
2. Go to http://localhost:8080/and click the “Manager App” button (or) go
tohttp://localhost:8080/manager/html
This will prompt for the user name and password. Enter the values from the tomcat-users.xml.
7.1. Start and Stop Server:
1. To start the tomcat server, go to C:\apache-tomcat-7.0.65\bin and find
startup.bat file and run it.
2. To stop the server, go to C:\apache-tomcat-7.0.65\bin and find shutdown.bat file
and run it.
Note: for starting server please make sure that your java home path should be configured in environment
variables. If not please follow the steps.

Go to --rightclick on MyComputer---properties--Advanced system Setting-Environment


Variables-new button on uservariables- enter variable name and variable value as shown in the
below screen.
7.2. Test Server:
After started server open web browser and go to http://localhost:8080/, then you should see
the following screen

7.3. Login to Manager App:


Click on Manger App, It will ask you for user name and password

Enter Correct User Name and Password and click on Login.

The below screen shows the web applications running on the tomcat server. If you want to
deploy your web application then you can deploy by creating the war file of your application.
 Downloading and installing the windows service installer file.

Download latest version of tomcat windows service installer from the below the following link
https://tomcat.apache.org/download-70.cgi

Double click on the tomcat windows installer file and Click on Next Button.
Click on I agree button.

Click on Next Button.


Leave the default values and click on Next button.

Select the path where you r java installed on your machine. Automatically it will take the path if not
select the path of the java and Click on Next button.

Select the path where you want to install the tomcat on your machine.
use the default path which shows on the screen (recommended) and Click on Next button.
It will start installing tomcat on your machine.

Once installation is complete it will show the below screen.


If you want to run apache tomcat server now then check the box ‘Run Apache Tomcat’ and Click on
Finish button otherwise uncheck the box of ‘Run Apache Tomcat’ and click on Finish button.

For testing run the apache tomcat server now. The below screen shows starting the apache tomcat
server.

Once the server starts running,


Add / update users and roles in tomcat-users.xml:

Note :catalina home means where the tocat is installed.


Open CATALINA_HOME/conf/tomcat-users.xml
Add the manager role and then alter an existing user (such as tomcat), as follows:
<?xmlversion='1.0'encoding='utf-8'?>
<tomcat-users>
<rolerolename="tomcat"/>
<rolerolename="admin-gui"/>
<rolerolename="manager-gui"/>
<userusername="tomcat"password="tomcat"roles="tomcat, manager-
gui,admin-gui"/>
</tomcat-users>
Access Manager Application:
3. Start Server(refer 15.3 step)
4. Go to http://localhost:8080/and click the “Manager App” button (or) go
tohttp://localhost:8080/manager/html
This will prompt for the user name and password. Enter the values from the tomcat-users.xml.

Test Server:
After started server open web browser and go to http://localhost:8080/, then you should see
the following screen

7.4. Login to Manager App:


Click on Manger App, It will ask you for user name and password

Enter Correct User Name and Password and click on Login.


The below screen shows the web applications running on the tomcat server. If you want to
deploy your web application then you can deploy by creating the war file of your application.

Configure Tomcat Server in Eclipse IDE


Open Servers View:
To open Servers View click on the Windows select Show View menu select Servers

Then you can see the Servers View as


Click on that blue colour line to create new server, it shows you New Server Wizard

Click on Next button.


You have to configure the installation path of the tomcat on your machine. If not installed you have
the download and install option.

Once configuring the path click on Finish button.


You will see new server in Servers View as below

Now you can test the tomcat server in eclipse IDE.


It will open browser and type the URL shown in the below screen and click on run button.

If the tomcat configuration is success then the following screen should be appear.
Oracle XE installation :

Download oracle from the below link

http://www.oracle.com/technetwork/database/database-
technologies/express-edition/downloads/index.html

accept license agreement

You might also like