Install JDK & Java & eclipse & MySql in Linux

Source: Internet
Author: User
Tags gtk

ISOFile:

Installation steps:

I. InstallationJDK

1. First download JDK

2. Copy jkd to/usr/local/web/(you can also copy it directly on the interface)

Mount/mnt/CDROM

CP/mnt/CDROM/jdk-6u13-linux-i586.bin/usr/local/web/

CD/usr/local/Web

/Jdk-6u13-linux-i586.bin

 

 

 

3. Finally, configure the JDK environment variable:

VI/etc/profile

Java_home =/usr/local/web/jdk1.6.0 _ 13

Path = $ path:/usr/local/web/jdk1.6.0 _ 13/bin

Classpath =.:/usr/local/web/jkd/1.6.0 _ 13/JRE/LIC/RT. Jar

Export java_home path classpath

ESC

: WQ

 

 

 

4. JDK installation is complete.

Next we will test whether JDK is successfully installed:

Copy the following content to notepad:

Public class hellojava {

Public static void main (string SRG []) {

System. Out. println ("Hello Java! ");

}

}

Save it as "hellojava. Java" (without quotation marks, the same below) and save it to the root directory of drive D. Enter the commands marked by the red line in the command line in sequence:

If the content marked in the red box appears, the JDK is successfully installed!
Note: If you want to install integrated development environments such as Eclipse, Borland JBuilder, jcreator, and intellij idea (IDE, integrated development environment) in the future, compile and run a simple helloworld program in the IDE, to ensure that the IDE can identify the JDK location.

 

Ii. InstallationTomcat

1. First download Tomcat

2. Copy apache-tomcat-6.0.26-src.tar.gz to/usr/local/web/, and decompress

Mount/mnt/CDROM

CP/mnt/CDROM/apache-tomcat-6.0.26-src.tar.gz/usr/local/web/

CD/usr/local/Web

Tar-zxvf apache-tomcat-6.0.26-src.tar.gz

 

Iii. InstallationMyEclipse(IfMyeclipseNot includedEclipseFirst installEclipse)

1. First download myeclipse

2. Copy myeclipse to/usr/local/web/and install it (you need to install it in the graphic interface)

CP/mnt/CDROM/myeclipse-7.1.1-linux-gtk-x86.tgz/usr/local/web/

CD/usr/local/Web

Tar-zxvf myeclipse-7.1.1-linux-gtk-x86.tgz

Startx

After entering the graphic interface, open the terminal and enter/usr/local/web/

CDS/usr/local/web/myeclipse-7.1.0-linux-gtk-x86/

/Myeclipse-71-installer

3. After installing myeclipse, open a new project,

 

 

3. Create a JSP page

 

4. Configure Tomcat menu windows -- preferences

 

 

5. Deploy (deployment) project

 

 

6. Start the Tomcat server

 

 

7. Run the website

 

Note: additional project creation practices

Although JSP files can be created using the above method, this method cannot automatically contain some class libraries in Tomcat, which may cause a lot of trouble after the project is deployed. Therefore, we recommend that you use the following method to create a project:

(1) In eclipse, perform the following operations: Eclipse> File> New> Project>. In the displayed window, select Java> Tomcat project to create a new project;

(2) after the project is created, right-click the project name in package Development E and choose myeclipse> Add webproject capabilities from the shortcut menu (as shown in ); after being added to this function, you can develop various web applications;

 

 

V. Install MySQL

1. Use the RPM package for Installation

First, you can download the RPM package of the corresponding version from the installation disc or to the MySQL website as follows:

MySQL-server-community-5.1.38-0.rhel5.i386.rpm

MySQL-client-community-5.1.38-0.rhel5.i386.rpm

Then we can use the RPM command for installation:

Rpm-IVH MySQL-server-community-5.1.38-0.rhel5.i386.rpm

Rpm-IVH MySQL-client-community-5.1.38-0.rhel5.i386.rpm

Ii. Install Binary packages

The procedure is as follows:

1. Use root to log on to the system and add mysql users and groups.

Groupadd MySQL

Useradd-G MySQL

2. decompress the Binary Package. If the Binary Package is stored in/home/MySQL, decompress the package and add a symbolic link.

Tar xvfz mysql-5.1.38-linux-i686-glibc23.tar.gz

Ln-s mysql-5.1.38-linux-i686-glibc23 MySQL

3. Create a system database table in the database directory. -- User indicates that the owner of these databases and tables is the user

CD MySQL

./Scripts/mysql_install_db -- user = MySQL

4. Set directory permissions and change the owner of the data directory to MySQL. The owner of files in other directories is root.

Chown-r root: MySQL.

Chown-r MYSQL: MySQL DATA

5. Start MySQL

./Bin/mysqld_safe -- user = MySQL &

Iii. Install MySQL with source code

1. Use root to log on to the system and add mysql users and groups.

Groupadd MySQL

Useradd-G MySQL

2. decompress the source code package and enter the decompressed directory.

Tar xvfz mysql-5.1.38.tar.gz

CD mysql-5.1.38

3. Use the configure tool to compile the source code. here we can use a lot of parameters. For details, see configure -- help. Here we will install MySQL under/usr/local/MySQL.

./Configure -- prefix =/usr/local/MySQL

Make

Make install

4. select a sample configuration file and copy it to/etc/and rename it my. CNF.

CP support-files/my-medium.cnf/etc/My. CNF

5. Create a system database table in the database directory. -- User indicates that the owner of these databases and tables is the user

CD/usr/local/MySQL

./Bin/mysql_install_db -- user = MySQL

6. Set directory permissions and change the owner of the VaR directory to MySQL. The owner of other directories and files is root.

Chown-r root.

Chown-r MySQL VaR

Chgrp-r MySQL.

7. Start MySQL

./Bin/mysqld_safe -- user = MySQL &

Check whether MySQL is started:

Netstat-anp | more

If Port 3306 exists, MySQL starts

Go to MySQL

CD/home/MySQL/bin

./MySQL-u root-P

Configure MySQL for any directory:

VI/root/. bash_profile

Add:/usr/local/MySQL/bin after path

Save

Reboot

In ENV, you can see the added Path in path.

Mysql-r root-P

 

 

 

 

 

 

 

 

 

 

 

Link MySQL to Java for testing:

1.Add the users table to the MySQL test database and insert data.

 

2. Copy the driver mysql-connector-java-5.1.7-bin.jar to/usr/local/web/jdk1.6.0 _ 13/JRE/lib/EXT /.

3. Create showuser. Java

VI showuser. Java

Import java. SQL .*;

 

Public class showuser {

Public static void main (string [] ARGs ){

Try {

Class. forname ("com. MySQL. JDBC. Driver ");

Connection Ct = drivermanager. getconnection ("JDBC: mysql: // 127.0.0.1: 3306/fortest? User = root & Password = ");

Statement Sm = CT. createstatement ();

Resultset rs1_sm.exe cutequery ("select * from users ");

While (Rs. Next ()){

System. Out. println ("username =" + Rs. getstring (2 ));

}

} Catch (exception e ){

E. printstacktrace ();

}

}

}

4. Compile and run showuser. Java

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.