Create server and deploy application on DigitalOcean Droplet
DigitalOcean Droplet, Linux, Java, Gradle, ChatGPT
- Setup and configure a server on DigitalOcean
- Create and configure a new Linux user on the Droplet
- Firewall Configuration Security Best Practice
- Deploy and run a Java Gradle application on Droplet
- Clone this repository:
git clone [email protected]:CharismaIsland/Basic-Cloud-Server-Deploy-Java-React-Maven-App.git cd cloud-basics-create-server
- Install Requirements:
- Java JRE SDK ver. 17 only
- Gradle ver. 8.14.3
- IntelliJ IDE (will be used to build gradle project)
For Windows
-
Find the Java installation path:
- Default: C:\Program Files\Java\jdk-
- Copy this path.
-
Set Java_Path:
-
Verify
- Open Commmand Prompt and run:
java -version
javac -version
echo %JAVA_HOME%For Linux/MacOS
- Find Java Installation Path
which java
readlink -f $(which java)- Set JAVA_HOME
- Open profile file:
- ~/.bashrc or ~/.zshrc
- Add:
- Open profile file:
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATHIf you encounter compatibility issues, copy error message into ChatGPT for step-by-step assisstance. Context Prompt:
I am trying to set the Java JAVA_HOME environment variable, but I’m running into an error.
Here is the exact message I see from my console/terminal:
"Copy and paste the exact message here"
help me figure out what’s causing this and how to fix it?Setup Digital Ocean Server or Cloud Provider of Choice
- Free Tier - Select Basic CPU - at least 1GB in region nearest to you
- Allow TCP Port 22 to Your IP only
- Create SSHKey to connect to server from your local PC
- Follow Instructions with Cloud Provider if you need to create your first SSHKey
- Open TCP Port 7071 (will be used to connect to App later http://localhost:7071)
Configure and Build Gradle
- Create a Gradle folder under C:\drive
- Copy download to new Gradle folder and unzip
- Use IntelliJ IDE - Open Folder where repo downloaded 'java-react-example'
- In IDE Terminal - Build Gradle Project - Run Command:
gradle build- Test App
java -jar ./build/libs/java-react-example.jar - Secure Copy .jar file from your local host to server public IP
scp build/libs/java-react-example.jar root@<replace_with_server_ip>:/root- Connect to Cloud server via SSH via Terminal or Putty (for Windows)
ssh root@<server-public-ip>- Run Java App On Server with Command:
java -jar java-react-example.jar - Connect App from Browser on http://localhost:7071
- Remember to terminate cloud server to avoid unnecesary costs
- All data is mock/simulated for educational purposes.
- Remember to Terminate Hosts
- Optimize and Add as you see fit
- Consider creating Terraform template for Infrastructure as Code


