$ ssh -i <key name> .pem ec2-user @ <public IP address>
$ sudo yum search java | grep jdk
$ sudo yum install -y java-1.8.0-openjdk.x86_64
$ sudo yum search java | grep jdk
ldapjdk-javadoc.noarch : Javadoc for ldapjdk
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK 8 accessibility
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment 8 with full debug
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos 8
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos 8 with full debug on
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 8 with
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 8
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK 8 API documentation for
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed
java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle 8
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 8 for packages with
ldapjdk.noarch : The Mozilla LDAP Java SDK
Install JRE 1.8.0
$ sudo yum install -y java-1.8.0-openjdk.x86_64
$ java -version
$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
It is 1.8.0 properly.
A jar file or Java Archive is a ZIP format compressed file that includes class files and image data included in a Java project.
Copy this file to the EC2 side and build it.
Move to the local (your PC) Spring project directory and generate a jar file with the command
$cd project directory
$ mvn clean package
## sftp connect
$ sftp -i <key name>.pem ec2-user@<Public IP address>
## file put
sftp> put target/<file name>.jar
--Set the java version of the Spring Boot project to 8
-> Play with the property in pom.xml
<properties>
<java.version>8</java.version>
</properties>
-> Change environment path
$ cd ~/.zshrc
$ vi .zshrc
##Add the following settings
export JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java_home -v "1.8"`
PATH=$JAVA_HOME/bin:$PATH
-> Don't forget to update at the end
$ source ~/.zshrc
$ ssh -i my-key.pem ec2-user @ <public IP address>
$ java -jar <filename> .jar
$ java -jar todo-app-0.0.1-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.3.RELEASE)
...
Security Group changes --Allow inbound rules to connect to port 8080
Recommended Posts