English 中文(简体)
JPA - Installation
  • 时间:2024-12-22

JPA - Installation


Previous Page Next Page  

This chapter takes you through the process of setting up JPA on Windows and Linux based systems. JPA can be easily installed and integrated with your current Java environment following a few simple steps without any complex setup procedures. User administration is required while installation.

System Requirements

JDK Java SE 2 JDK 1.5 or above
Memory 1 GB RAM (recommended)
Disk Space No minimum requirement
Operating System Version Windows XP or above, Linux

Let us now proceed with the steps to install JPA.

Step1: Verify your Java Installation

First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the following two commands depending on the platform you are working on.

If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.

Platform Command Sample Output
Windows

Open command console and type:

>java –version

Java version "1.7.0_60"

Java (TM) SE Run Time Environment (build 1.7.0_60-b19)

Java Hotspot (TM) 64-bit Server VM (build 24.60-b09,mixed mode)

Linux

Open command terminal and type:

$java –version

java version "1.7.0_25"

Open JDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64)

Open JDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Step 2: Set your Java Environment

Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,

Platform Description
Windows Set JAVA_HOME to C:ProgramFilesjavajdk1.7.0_60
Linux Export JAVA_HOME=/usr/local/java-current

Append the full path of Java compiler location to the System Path.

Platform Description
Windows Append the String "C:Program FilesJavajdk1.7.0_60in" to the end of the system variable PATH.
Linux Export PATH=$PATH:$JAVA_HOME/bin/

Execute the command java -version from the command prompt as explained above.

Step3: Instalpng JPA

You can go through the JPA installation by using any of the JPA Provider from this tutorial, E.g. Ecppsepnk, Hibernate. Let us follow the JPA installation using Ecppsepnk. For JPA programming we require to follow the specific folder framework therefore it is better to use IDE.

Download Ecppse IDE form following pnk https://www.ecppse.org/downloads/ Choose the EcppseIDE for JavaEE developer that is Ecppse indigo.

Unzip the Ecppse zip file in C drive. Open Ecppse IDE.

Instalpng JPA

Instalpng JPA using Ecppsepnk

Ecppsepnk is a pbrary therefore we cannot add it directly to Ecppse IDE. For instalpng JPA using Ecppsepnk you need to follow the following steps.

    Create a new JPA project by selecting File->New->JPA Project in the Ecppse IDE as follows:

    New JPA

    You will get a dialog box named New JPA Project. Enter project name ‘tutorialspoint_JPA_Ecppsepnk’, check the jre version and cpck next:

    Dialog Box

    Cpck on download pbrary (if you do not have the pbrary) in the user pbrary section:

    Download Library

    Select the latest version of Ecppsepnk pbrary in the Download pbrary dialog box and cpck next as follows:

    Download Library Dialog Box

    Accept the terms of pcense and cpck finish for download pbrary as follows:

    License

    You will find the process of downloading a file as follows:

    Process

    After downloading, select the downloaded pbrary in the user pbrary section and cpck finish as follows:

    Library Section

    Finally you get the project file in the Package Explorer in Ecppse IDE. Extract all files, you will get the folder and file hierarchy as follows:

    Package Explorer

Adding MySQL connector to Project

Any example that we discuss here are mandatory to mingle with database. Let us consider MySQL database for database operations. It requires mysql-connector jar to interact with java program.

Follow the steps to configure database jar to your project.

    Go to Project properties -> Java Build Path by right cpck on it. You will get a dialog box as follows: Cpck on Add External Jars.

    External Jars

    Go to the jar location in your system memory, select and cpck on open as follows:

    Jar Location

    Cpck ok on properties dialog. You will get the MySQL-connector Jar into your project. Now you are able to do database operations using MySQL.

Advertisements