How to Deploy Java Spring Boot Application on Shared cPanel
How to Deploy Java Spring Boot Application on Shared cPanel (Without Terminal Access)
Table of Contents
Many developers want to deploy a Java Spring Boot project on shared cPanel hosting, but face a challenge:
- Shared hosting is optimized for PHP apps (WordPress, Laravel, etc.).
- Java apps require JVM, custom ports, and sometimes Tomcat, which is rarely supported in shared hosting.
This guide explains possible methods to run a Spring Boot application on shared cPanel without SSH/terminal access.
✅ Step 1: Verify Java Support in Your Hosting
- Log in to your cPanel account.
- In the search bar, type “Java” or “Tomcat”.
- If you see Tomcat Manager / Java Selector / Application Manager, then your hosting supports Java.
- If not, you will have to use a workaround method (explained in Step 5).
⚠️ Note: Not all shared hosting providers allow Java. If your provider doesn’t support it at all, you will need VPS or specialized Java hosting.
✅ Step 2: Build Your Spring Boot Application
On your local machine, package your Spring Boot project:
- For Maven:
mvn clean package - For Gradle:
./gradlew build
- If your project is configured with:
<packaging>war</packaging>→ You will get a WAR file insidetarget/yourapp.war. - If packaging is default → You will get a JAR file inside
target/yourapp.jar.
✅ Step 3: Upload Application to cPanel
- Go to cPanel → File Manager.
- Navigate to a directory, e.g.,
/home/username/javaapp/. - Upload your WAR/JAR file here.
✅ Step 4: Deploy via Tomcat (If Available in cPanel)
If your hosting supports Tomcat:
- Open cPanel → Tomcat Applications / Java Applications.
- Click Deploy WAR.
- Select your uploaded
yourapp.war. - After deployment, your app will be available at:
https://yourdomain.com/yourapp/(Or at root if mapped by your host.)
This is the cleanest way to run Spring Boot on shared hosting.
✅ Step 5: Deploy JAR File Using Cron Jobs (No Tomcat Available)
If your host does not provide Tomcat, but allows Java execution:
- Create a startup script
On your local system, create a file namedstart.shwith the following content:#!/bin/bash cd /home/username/javaapp/ nohup java -jar yourapp.jar > app.log 2>&1 &- This will start your Spring Boot app in the background.
nohupensures it runs even after the cron job finishes.app.logwill contain logs for debugging.
- Upload the script
Uploadstart.shto yourjavaappfolder in cPanel File Manager. - Set file permissions
In File Manager → right-clickstart.sh→ Permissions → make it executable (usually0755). - Run script via Cron Job
- Go to cPanel → Cron Jobs.
- Add a new cron job with command:
sh /home/username/javaapp/start.sh - Set it to run once (or at reboot if available).
- Access your app
- By default, Spring Boot runs on port
8080. - Shared hosts often block custom ports, so you may need to ask your hosting provider to map your domain/subdomain to your app’s port (reverse proxy).
- Example:
yourdomain.com → maps to → serverIP:8080
- By default, Spring Boot runs on port
✅ Step 6: (Optional) Create Stop Script
To stop your app if needed, create a stop.sh:
#!/bin/bash
pkill -f 'yourapp.jar'
Upload it and run it via cron job when required.
✅ Step 7: Limitations of Shared Hosting
- Custom Ports Restricted → You may not get direct access without reverse proxy support.
- No Root/Terminal Access → You cannot install or manage JVM versions yourself.
- Resource Limits → Shared servers may kill heavy apps (Spring Boot apps use more memory than PHP).
- Not Ideal for Production → For long-term stable hosting, use VPS/Cloud.
✅ Step 8: Best Alternatives
If your provider doesn’t support Java:
- Or use a cheap VPS ($5/month) from Yash Host.
- Deploy with NGINX/Apache reverse proxy for production-grade setup.
🎯 Conclusion
Yes, it is possible to deploy a Spring Boot app on shared cPanel without terminal access, but with limitations.
- Best Case: Use Tomcat in cPanel and deploy a WAR file.
- Workaround: Use cron jobs to run your Spring Boot JAR.
- Recommended for Production: Use VPS or Java-optimized hosting for full stability.
