Java Open Source Practice (1)--Environment configuration

Source: Internet
Author: User
Tags character set gz file mysql net variables variable zip jboss

Java Open Source Practice 1--environment Configuration



Wuder
The software required for deploy under Window System:
The following software is executed under window

Jdk5.0

Download Address: http://java.sun.com/j2se/1.5.0/download.jsp

Jdk-1_5_0_01-windows-i586-p.exe

Jboss4.01

Download Address: http://prdownloads.sourceforge.net/jboss/

Jboss-4.0.1sp11.zip

Mysql4.1

Download Address: http://dev.mysql.com/downloads/mysql/4.1.html

Mysql Server 4.1

Mysql JDBC Driver

Download Address: http://mirror.etf.bg.ac.yu/mysql/Downloads/Connector-J/

Mysql-connector-java-3.1.7.zip

Ant1.6.2

Download Address: http://ant.apache.org/

Apache-ant-1.6.2-bin.zip








Installation steps
One, install JDK1.5;







Second, install Jboss4.01;







Third, install Mysql4.1;







Create a new database:







Command is: CREATE DATABASE PPP character set UTF8;















Four, the ant to untie, put into a folder;







Five, set environment variable; (My Computer > Properties > Advanced > Environment Variables > System variables)







New variable:







Ant_home=[ant Path]







java_home=[jdk5.0 Installation Path]







Class_path=%java_home%\lib







To modify a variable:







PATH append, with ";" Interval. %ant_home%\bin;%java_home%\bin; [MySQL installation road]\bin;















Place the Mysql-connector-java-3.1.7-bin.jar (MySQL JDBC driver) in the [JBoss installation path] Erver\default\lib.















Seven, modify Jboss-service.xml.







<attribute name= "URLs" >







Deploy







</attribute>







Modified to:







<attribute name= "URLs" >







deploy/,file:/e:/dep/web/, file:/e:/dep/ejb/







</attribute>







E:/DEP/WEB,E/DEP/EJB for deploy file folder, you can also put to other places, but in Jboss-service.xml set.















Eight, find Mysql-ds.xml (location: [JBoss folder]\docs\examples\jca)







Modify and place in [JBoss folder] Erver\default\deploy







The contents are as follows:















<jndi-name>MySqlDS</jndi-name>







<connection-url>jdbc:mysql://localhost:3306/ppp[the same pc]</connection-url>







<driver-class>com.mysql.jdbc.Driver</driver-class>







<user-name>root</user-name>







<password>[Set the password]</password>







<connection-property name= "Useunicode" >true</connection-property>







<connection-property name= "Characterencoding" >utf8</connection-property>























Nine, use the Ant build Yywap project.







start>>run>> cmd (carriage return)







Current directory move to Yywap project folder







The results are as follows:

C:\test\yywap>ant







Buildfile:build.xml















...... Omitted















Build successful







Total time:1 minute seconds















Ten, put the program in the Deploy directory (location in yywap/target)







E:\DEP\EJB into Yyejb.jar







E:\dep\web into Yyweb.war























11, start Mysql and Jboss.







Startup program scripts are







[MySQL Path]/bin/mysql.exe







[Jboss]/bin/run.bat















Jboss Stop command: shutdown–s















Test:







Open Internet Explorer, URL is







Http://localhost:8080/wap/faces/admin/co/listAll.do






























































Software required for deploy under Linux systems:
The following software is implemented under Linux

Jdk5.0

Download Address: http://java.sun.com/j2se/1.5.0/download.jsp

Jdk-1_5_0_01-linux-i586.bin

Jboss4.01

Download Address: http://prdownloads.sourceforge.net/jboss/

Jboss-4.0.1sp1.tar.gz

Mysql4.1

Download Address: http://dev.mysql.com/downloads/mysql/4.1.html

Mysql-standard-4.1.10-pc-linux-gnu-i686.tar.gz

Mysql JDBC Driver

Download Address: http://mirror.etf.bg.ac.yu/mysql/Downloads/Connector-J/

Mysql-connector-java-3.1.7.tar.gz

Ant1.6.2

Download Address: http://ant.apache.org/

Apache-ant-1.6.2-bin.tar.gz
























Installation steps
Install the Linux version of Red Hat 9.0 and use user root to log in when operating.









One, install JDK1.5;















Run this installer,shell>./[bin FileName]







Appear "more" press ENTER, if you choose "Yes" or "No", type Yes, enter.







JDK Installation Location:/usr/java/jdk1.5.0_01















Second, install MySQL 4.1; (Lookup document extract directory install_binary)







Right-click the mouse to open a terminal window. Enter the following command:















shell> Groupadd MySQL







shell> useradd-g MySQL MySQL







Shell> cd/usr/local[First to copy mysql.tar.gz file to/usr/local]







Shell> gunzip </path/to/mysql-version-os.tar.gz[tar.gz file name] | Tar-vxzf







[Unzip, generate a folder with the same name as the tar.gz file]







shell> ln-s Full-path-to-mysql-version-os MYSQL







[After decompression, for a folder that has the same name as the tar.gz file and make a soft connection to the MySQL directory]







shell> CD MySQL







Shell> scripts/mysql_install_db--user=mysql







Shell> chown-r Root.







shell> chown-r MySQL Data







Shell> chgrp-r MySQL.







Shell> bin/mysqld_safe--user=mysql & This command for starting MySQL















shell> CD [MySQL path]/bin







shell> MySQL







> CREATE database PPP character set UTF8; Create a new database PPP























Tips:















Shell>pwd is used to get the current directory







Shell>ls View the contents of the current directory







Shell>cd.. Return to the previous level of a directory







Shell>cd/www/www to set the current directory to/www/www















shell>mysqladmin-u root-p Password [mysql new password] reset the MySQL password, will let you enter the old password







Shell>mysqladmin shutdown shut down MySQL service































Third, install Jboss4.01







Unpack, put into a directory















Four, the ant to untie, put into a folder;







shell> TAR-VXZF [GZ filename]















Five, set the environment variable;















Ant_home=[ant Path]







java_home=[jdk5.0 Installation Path]







Class_path=%java_home%\lib







To modify a variable:







PATH Append, with the ":" Interval. %ant_home%\bin;%java_home%\bin:[mysql installation Road]\bin;















Operation Steps:







1. Open a terminal window.







2. Determine the current directory is/root, using the shell command CD, PWD complete.







3. Type the command gedit. Bash_profile







Shell> gedit. Bash_profile







4. Modify. Bash_profile, the specific path, the current installation is quasi.







5. Type the command source. Bash_profile to enable Linux to apply this setting immediately.







Shell> source. bash_profile







6. Type echo $PATH [environment variables] to see if they are valid.







Shell> Echo $PATH























The contents of the. bash_profile file are attached below. The corresponding path should be modified.







#. Bash_profile















# get the aliases and functions







If [f ~/.BASHRC]; Then







. ~/.bashrc







Fi















# User specific environment and startup programs















Java_home=/usr/java/jdk1.5.0_01







ant_home=/home/wubing/ev/apache-ant-1.6.2







MYSQL =/usr/local/mysql







Path= $PATH: $HOME/bin: $JAVA _home/bin: $ANT _home/bin: $MYSQL/bin







Classpath=%java_home%\lib\tools.jar:%java_home%\lib\dt.jar







bash_env= $HOME/.BASHRC







Username= "Root"















Export Java_home ant_home mysql_home PATH CLASSPATH USERNAME bash_env























VI, add the MySQL driver jar and place the Mysql-connector-java-3.1.7-bin.jar (MySQL JDBC driver) in the [JBoss installation path] Erver\default\lib.























Seven, set the MySQL data source. Find Mysql-ds.xml (location: [JBoss folder]\docs\examples\jca)







Modify and place in [JBoss folder] Erver\default\deploy







The contents are as follows:















<jndi-name>MySqlDS</jndi-name>







<connection-url>jdbc:mysql://localhost:3306/ppp[the same pc]</connection-url>







<driver-class>com.mysql.jdbc.Driver</driver-class>







<user-name>root</user-name>







<password>[Set the password]</password>







<connection-property name= "Useunicode" >true</connection-property>







<connection-property name= "Characterencoding" >utf8</connection-property>























Eight, use the Ant build Yywap project.















Current directory move to Yywap project folder







SEHLL&GT;CD [Yywap Path]







Shell>ant execution Ant







The results are as follows:

Buildfile:build.xml















...... Omitted















Build successful







Total time:1 minute seconds















Nine, put the program in the Deploy directory (program location in Yywap/target)







Yyejb.jar,yyweb.war to [JBoss folder] Erver\default\deploy























Ten, start Mysql and Jboss.







Startup program scripts are







[mysql]/bin/







[jboss]/bin/







Start MySQL







sheel>./mysqld_safe--user=mysql &







Sheel>./mysqladmin shutdown















Jboss







Start sheel>./run.sh







Stop:sheel>./shutdown.sh–s















11, the result







Under normal circumstances, JBoss startup should have no error messages. The error situation is generally







MySQL data source set incorrectly, (for attention password)







MySQL driver is not placed in the Deploy/lib directory.







MySQL does not have new PPP databases.























Database changes:







Command: Shell>mysql







>show databases;







should see database PPP







>use PPP;







>show tables;







Should be seen to have added some tables. These tables are automatically added when deploy EJB.







Test:







Open Mozilla, URL is







Http://localhost:8080/listAll.do
























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.