Development in Ubuntu
Ubuntu Install
Download Ubuntu LTS from https://ubuntu.com/#download.
Make Bootable USB
On Window System, See http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows.
On Ubuntu System, Follow the instructions below.
Insert the USB and check the USB device.
sudo ls -l /dev/disk/by-id/*usb*
If sdb, sdb1, and sdb2 show together, sdb is a USB device. Navigate to the Ubuntu ISO file folder and execute the following command:
sudo dd if=filename.iso of=/dev/sdb bs=4M; sync
Replace filename.iso with the downloaded Ubuntu ISO file name and replace /dev/sdb with your USB device.
How to install Oracle 11g XE on Ubuntu
Ubuntu is not a Linux distribution officially supported by Oracle.
You can install Oracle 11g XE on Ubuntu with a few tricks.
Origin: http://meandmyubuntulinux.blogspot.kr/2012/05/installing-oracle-11g-r2-express.html
Visit https://www.oracle.com/database/technologies/xe-prior-release-downloads.html. For 64-bit systems, choose Oracle Database Express Edition 11g Release 2 for Linux x64. You need to log in to download the file. --Sign up if you are not a member of the Oracle website-- When you log in to the site, the download begins. After downloading, go to the directory where the file exists and execute the following command.
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
sudo apt install alien unixodbc
sudo apt install libaio1
- sudo apt install libaio1 fails in Ubuntu 24.04
-
Ubuntu 24.04 does not support libaio1.
Install libaio-dev instead.sudo apt install libaio-dev
Oracle 11g XE still expecting libaio.so.1, so create the following symbolic link:sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1
cd Disk1 sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
Create a /sbin/chkconfig file.
sudo nano /sbin/chkconfig
Copy and Paste the following into the file.
#!/bin/bash # Oracle 11gR2 XE installer chkconfig hack for Ubuntu file=/etc/init.d/oracle-xe if [[ ! `tail -n1 $file | grep INIT` ]]; then echo >> $file echo '### BEGIN INIT INFO' >> $file echo '# Provides: OracleXE' >> $file echo '# Required-Start: $remote_fs $syslog' >> $file echo '# Required-Stop: $remote_fs $syslog' >> $file echo '# Default-Start: 2 3 4 5' >> $file echo '# Default-Stop: 0 1 6' >> $file echo '# Short-Description: Oracle 11g Express Edition' >> $file echo '### END INIT INFO' >> $file fi update-rc.d oracle-xe defaults 80 01
Save the above file and provide appropriate execute privilege.
sudo chmod 755 /sbin/chkconfig
Set the Kernel parameters.
sudo nano /etc/sysctl.d/60-oracle.conf
Copy the following. Paste it into the file.
# Oracle 11g XE kernel parameters fs.file-max=6815744 net.ipv4.ip_local_port_range=9000 65000 kernel.sem=250 32000 100 128 kernel.shmmax=536870912
Check the swap memory.
free -m
total used free shared buffers cached Mem: 3942 3809 133 947 50 1571 -/+ buffers/cache: 2186 1756 Swap: 4083 378 3705
Unlike the above, if Swap doesn't exceed 4000, do the following.
sudo ln -s /usr/bin/awk /bin/awk sudo mkdir /var/lock/subsys sudo touch /var/lock/subsys/listener
Verify the kernel parameters.
sudo cat /etc/sysctl.d/60-oracle.conf
Load kernel parameters.
sudo service procps restart
Verify.
(In my case, it came out differently from the set value, but I was able to complete the installation)
sudo sysctl -q fs.file-max
Go to the Disk1 directory and run the following commands:
sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb sudo /etc/init.d/oracle-xe configure
- Specify the HTTP port that will be used for Oracle Application Express: Set a value other than 8080, like 9090
- Specify a port the database listener: (just hit Enter)
- Set passwords for administrator accounts SYS and SYSTEM: Password for Oracle administrators, you specified
- Do you want Oracle Database 11g Express Edition to be started on boot: (just hit Enter)
Oracle Database 11g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 11g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press Enter to accept the defaults. Ctrl-C will abort. Specify the HTTP port that will be used for Oracle Application Express [8080]:9090 Specify a port that will be used for the database listener [1521]: Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: ********** Confirm the password: ********** Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]: Starting Oracle Net Listener...Done Configuring database...Done Starting Oracle Database 11g Express Edition instance...Done Installation completed successfully.
Set up the environmental variables.
nano ~/.bashrc
Add the following lines to your .bashrc:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe export ORACLE_SID=XE export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh` export ORACLE_BASE=/u01/app/oracle export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export PATH=$ORACLE_HOME/bin:$PATH
Execute the following command to load the changes:
source ~/.bashrc
Start the Oracle.
sudo service oracle-xe start
Create SCOTT account
Start SQL*PLUS and login as sys:
sqlplus sys as sysdba SQL*Plus: Release 11.2.0.2.0 Production on Wed May 9 12:12:16 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Enter password: ********** Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production SQL>@/u01/app/oracle/product/11.2.0/xe/rdbms/admin/utlsampl.sql
MySQL Install
sudo apt install mysql-server mysql-client
JDK Install
sudo apt update sudo apt upgrade sudo apt install default-jdk
Confirm java verion.
java -version
JDBC Test
Create a GetEmp.java as shown below.
import java.sql.*; public class GetEmp { public static void main(String[] args) { String URL = "jdbc:oracle:thin:@127.0.0.1:1521:XE"; String USER = "scott"; String PW = "tiger"; Connection conn = null; Statement stmt = null; ResultSet rs = null; String query = "SELECT * FROM emp"; try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { conn = DriverManager.getConnection(URL, USER, PW); stmt = conn.createStatement(); rs = stmt.executeQuery(query); while (rs.next()) { String empno = rs.getString(1); String ename = rs.getString(2); String job = rs.getString(3); String mgr = rs.getString(4); String hiredate = rs.getString(5); String sal = rs.getString(6); String comm = rs.getString(7); String depno = rs.getString(8); System.out.println(empno + " : " + ename + " : " + job + " : " + mgr + " : " + hiredate + " : " + sal + " : " + comm + " : " + depno); } } catch (Exception e) { e.printStackTrace(); } finally { try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) {} } } }
Move to directory containing the GetEmp.java file and execute the following commands:
javac GetEmp.java java -cp .:/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar GetEmp
Maven Install
Download the latest binary file from https://maven.apache.org/download.cgi, unzip it, and Move the generated directory to /opt.
cd ~/Downloads/ tar -xvzf apache-maven-3.5.4-bin.tar.gz sudo mv apache-maven-3.5.4/ /opt/maven
Open .bashrc file.
nano ~/.bashrc &
Copy the following and paste it into .bashrc file.
export MAVEN_HOME=/opt/maven export PATH=$MAVEN_HOME/bin:$PATH
Execute the following command to load the changes:
source ~/.bashrc
Check the Maven version.
mvn -v
Tomcat Install
Install Tomcat.
sudo apt update sudo apt upgrade sudo apt install tomcat8
Visit http://localhost:8080 and check the CATALINA_HOME and CATALINA_BASE directors at http://localhost:8080. Confirm the /conf/Catalina/localhost directory in your file system. (This directory is in either CATALINA_HOME or CATALINA_BASE)
Eclipse Install
Download Eclipse IDE for Java EE Developers from https://www.eclipse.org/downloads/packages/ and Unzip it as follows.
tar -xvf eclipse-jee-luna-SR2-linux-gtk-x86_64.tar.gz
Move the generated eclipse directory to the /opt directory.
sudo mv eclipse /opt/
Create an eclipse.desktop file
cd ~/.local/share/applications/ nano eclipse.desktop
Copy the following and paste it into eclipse.desktop file.
[Desktop Entry] Name=Eclipse Type=Application Exec=/opt/eclipse/eclipse Terminal=false Icon=/opt/eclipse/icon.xpm Comment=Integrated Development Environment NoDisplay=false Categories=Development;IDE Name[en]=eclipse.desktop
Search for eclipse and run it.
Register Eclipse to the launcher.
Git Install
sudo apt install git
Check the git version.
git --version
Set user information.
git config --global user.name "John Doe" git config --global user.email johndoe@gmail.org
Verify.
git config --global --list
SpringBoard Example Test
To install the SpringBbs project, execute the following command:
git clone https://github.com/kimjonghoon/SpringBbs
Go to the directory containing the ojdbc6.jar file and execute the following command to save the Oracle JDBC driver to your local repository.
cd /u01/app/oracle/product/11.2.0/xe/jdbc/lib mvn install:install-file -Dfile=ojdbc6.jar \ -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.2.0 -Dpackaging=jar
Start eclipse and Import SpringBbs into Eclipse.
Select the project in the Package Explorer view, click the mouse's right button to open the context menu, and select Maven - Update Project Configuration to synchronize pom.xml with Eclipse.
Create tables
Connect to the system account (sqlplus sys as sysdba) and execute the following SQL statements.
sqlplus sys as sysdba Copyright (c) 1982, 2011, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO java IDENTIFIED BY school; conn java/school Connected. create table member ( email varchar2(60) PRIMARY KEY, passwd varchar2(200) NOT NULL, name varchar2(20) NOT NULL, mobile varchar2(20) ); create table board ( boardcd varchar2(20), boardnm varchar2(40) NOT NULL, boardnm_ko varchar2(40), constraint PK_BOARD PRIMARY KEY(boardcd) ); create table article ( articleno number, boardcd varchar2(20), title varchar2(200) NOT NULL, content clob NOT NULL, email varchar2(60), hit number, regdate date, constraint PK_ARTICLE PRIMARY KEY(articleno), constraint FK_ARTICLE FOREIGN KEY(boardcd) REFERENCES board(boardcd) ); create sequence SEQ_ARTICLE increment by 1 start with 1; create table comments ( commentno number, articleno number, email varchar2(60), memo varchar2(4000) NOT NULL, regdate date, constraint PK_COMMENTS PRIMARY KEY(commentno) ); create sequence SEQ_COMMENTS increment by 1 start with 1; create table attachfile ( attachfileno number, filename varchar2(50) NOT NULL, filetype varchar2(30), filesize number, articleno number, email varchar2(60), constraint PK_ATTACHFILE PRIMARY KEY(attachfileno) ); create sequence SEQ_ATTACHFILE increment by 1 start with 1; create table authorities ( email varchar2(60) NOT NULL, authority varchar2(20) NOT NULL, constraint fk_authorities FOREIGN KEY(email) REFERENCES member(email) ); CREATE UNIQUE INDEX ix_authorities ON authorities(email, authority); create table views ( no number, articleNo number, ip varchar(60), yearMonthDayHour char(10), constraint PK_VIEWS PRIMARY KEY(no), constraint UNIQUE_VIEWS UNIQUE(articleNo, ip, yearMonthDayHour) ); create sequence SEQ_VIEWS increment by 1 start with 1; -- for test records insert into board values ('chat', 'Chat', '자유게시판'); commit;
Create tables (If you use MYSQL)
Connect to the root account. After installation, the password for the root account is "" so that you can press Enter and connect.
mysql --user=root --password mysql
Execute the following commands:
mysql --user=root --password mysql create user 'java'@'%' identified by 'school'; grant all privileges on *.* to 'java'@'%'; create database javaskool; exit; mysql --user=java --password javaskool create table member ( email varchar(60) PRIMARY KEY, passwd varchar(200) NOT NULL, name varchar(20) NOT NULL, mobile varchar(20) ); create table authorities ( email VARCHAR(60) NOT NULL, authority VARCHAR(20) NOT NULL, CONSTRAINT fk_authorities FOREIGN KEY(email) REFERENCES member(email) ); CREATE UNIQUE INDEX ix_authorities ON authorities(email,authority); create table board ( boardcd varchar(20), boardnm varchar(40) NOT NULL, boardnm_ko varchar(40) NOT NULL, constraint PK_BOARD PRIMARY KEY(boardcd) ); create table article ( articleno int NOT NULL AUTO_INCREMENT, boardcd varchar(20), title varchar(200) NOT NULL, content text NOT NULL, email varchar(60), hit bigint, regdate datetime, constraint PK_ARTICLE PRIMARY KEY(articleno), constraint FK_ARTICLE FOREIGN KEY(boardcd) REFERENCES board(boardcd) ); create table comments ( commentno int NOT NULL AUTO_INCREMENT, articleno int, email varchar(60), memo varchar(4000) NOT NULL, regdate datetime, constraint PK_COMMENTS PRIMARY KEY(commentno) ); create table attachfile ( attachfileno int NOT NULL AUTO_INCREMENT, filename varchar(255) NOT NULL, filetype varchar(255), filesize bigint, articleno int, email varchar(60), filekey varchar(255), creation datetime, constraint PK_ATTACHFILE PRIMARY KEY(attachfileno) ); create table views ( no int primary key AUTO_INCREMENT, articleNo int, ip varchar(60), yearMonthDayHour char(10), unique key (articleNo, ip, yearMonthDayHour) ); insert into board values ('chat','Chat','자유게시판'); commit; exit;
Test on Tomcat
Open the WebContants.java file in the net.java_school.commons package and modify the upload directory to match your system.
Go to the upload directory and execute the following command.
chmod 777 .
Go to the root directory and compile with the following command:
mvn clean compile war:inplace
Create a ROOT.xml file in /conf/Catalina/localhost.
If /home/johndoe/SpringBbs is the root directory, write it like below:
<?xml version="1.0" encoding="UTF-8"?> <Context docBase="/home/johndoe/SpringBbs/src/main/webapp" reloadable="true"> </Context>
Restart Tomcat.
systemctl restart tomcat8
Visit http://localhost:8080.
Test with Maven Jetty Plugin
If you test with Maven Jetty Plugin, you do not need a WAS like Tomcat, and you do not need to modify the permissions on the upload directory.
Stop Tomcat.
systemctl stop tomcat8
Delete all artifacts generated by Maven build.
mvn clean
In the pom.xml file, uncomment the build element under <!-- $ mvn jetty:run -->. Comment out the build element under <!-- $ mvn compile war:inplace and run tomcat -->. Go to the root directory and start Jetty with the following command:
mvn jetty:run
Go to http://localhost:8080.
Install Google Cloud SDk
Original: https://cloud.google.com/sdk/docs/downloads-apt-get
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee \ -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt update && sudo apt install google-cloud-sdk
sudo apt install google-cloud-sdk-app-engine-java
gcloud initReferences