If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Java program on web hosting

Started by sduggal, Jan 16, 2023, 01:10 AM

Previous topic - Next topic

sduggalTopic starter

My Intellij Idea has a Maven project that contains a Java program. While everything runs smoothly when the program is executed through the IDE, I need to upload it to the hosting server and run it from there. However, I encountered several difficulties along the way, as there were gaps in my knowledge. This led me to raise some questions:
1) Is it a requirement for the hosting service to support java?
2) Which file type should I extract from my project, .jar or .war? Additionally, how do I correctly create this file using Intellij Idea?
3) What steps do I need to perform in order to run the program on the hosting server?
  •  

chandanthaver

To delve deeper into the topic, it is recommended to study the relevant theory and familiarize yourself with the functioning of servlets, JSP and JSF. By doing so, you will comprehend that at the very least, a web container is necessary to execute them.

Among the simplest and most commonly used options are the Apache Tomcat and Jetty containers. It is advisable to download them, install them onto your personal computer, and carefully study their documentation. Play around with the settings and attempt to manually deploy your applications. After this step, become better acquainted with the concept of an "application server," and explore other container types.

Additionally, downloading two of the most popular container options - Glassfish and Wildfly - and experimenting with them can prove beneficial. Adjust the settings, try deploying your applications on them and once everything works flawlessly on your local computer, proceed to purchase a VPS and install the server that you found most beneficial throughout your experiments.

Another viable option is to embed the server in your application and launch it through a platform like Heroku.
  •  

webxerossolutions

Firstly, install Java onto a VDS with Linux. After which, extract the .jar file that corresponds with your application. Finally, execute the command "java -jar filename.jar" to run the program.

If you desire further knowledge surrounding this topic, visit https://www.heroku.com/ or purchase a monthly VPS with Linux from a hosting provider such as https://uahosting.com.ua/vps.php. In these environments, you will be able to independently configure all aspects of the Java environment and deploy your applications. Once executed, the program will be accessible via the designated IP address and port.

This is an excellent training exercise and recommended for those who are new to the field. Additionally, there are many other interesting concepts to learn about such as Github, Jenkins, Docker, and more.
  •  

AutumnSadness

For beginner developers and system administrators, deploying executable code on a server can be quite challenging. Hence, this guide has been compiled in hopes of aiding individuals in launching their projects without the assistance of highly experienced colleagues. However, it must be noted that while this resource is comprehensive, it may not be universal. Some level of interpretation might be required with consideration to specific systems.

If you prefer experimenting first, cloud servers by Timeweb Cloud provider offer a diverse selection of tariffs, including pre-designed solutions and virtual machines. To deploy your Java application onto the server, you will require a functioning website created in the Spring Boot framework.
  •  

fizzer

1) Yes, it is a requirement for the hosting service to support Java if you want to run your Java program on the server. Most hosting services provide support for Java, but you should verify this with your specific hosting provider.

2) The choice between a .jar or .war file depends on your application's requirements. A .jar (Java Archive) file is typically used for standalone Java applications, while a .war (Web Application Archive) file is used for Java web applications. If your project is a web application, you should create a .war file. To create these files in IntelliJ IDEA, follow these steps:

- For a .jar file, go to "File" -> "Project Structure" -> "Artifacts" -> click the "+" button -> "JAR" -> "From modules with dependencies". Select your main class and any necessary libraries, then click "OK", and finally, build the artifact by going to "Build" -> "Build Artifacts" -> select your artifact -> "Build". This will create a .jar file in the output folder.

- For a .war file, go to "File" -> "Project Structure" -> "Artifacts" -> click the "+" button -> "Web Application: Archive". Configure the necessary settings, such as the web.xml deployment descriptor and any libraries required by your web application. Once configured, click "OK", and finally, build the artifact by going to "Build" -> "Build Artifacts" -> select your artifact -> "Build". This will create a .war file in the output folder.

3) To run your program on the hosting server, you need to follow these general steps:

- Upload the .jar or .war file to the server. This can usually be done through an FTP client or through the hosting provider's control panel.

- SSH into the server (if necessary) and navigate to the directory where you uploaded the file.

- Run the program using the appropriate command. For a .jar file, you can use the command "java -jar filename.jar". For a .war file, you typically need a Java Application Server (e.g., Apache Tomcat) installed on the server. You can deploy the .war file to the application server and start it from there.

  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...