Deploying JAR in JBOSS - java

Im having a jar file(for java classes) with some associated files of my project.Its bacially a client/server based application,but not web based.How can I run this program in a machine(24*7)?
How can i deploy it in any application server?

You don't need JBoss or any other application server. Just start it:
java -jar yourfile.jar
and it will run 24/7. To start it in the background, add " &" to it. If you look for ways to start it automatically, with the system your could use init.d (if on unix/linux).
If you want to use an application server anyway, just wrap your jar in a war file and deploy it. This can be done using Ant's War Task or maybe directly from your IDE.

Related

How to properly deploy .jar file using Tomcat (Or another solution?) on an EC2 instance

So I have a Spring API which I packaged as a .jar file. I would like to run this perpetually on my EC2 instance. I have downloaded tomcat 8.5 from aws-extras onto my instance and have placed the jar file in the .lib subfolder and started tomcat but I can't query the API.
Am I missing a step or is there a better way to do this without Tomcat?
The API works when run with java, but I would like a solution that has it constantly running on the server.
The easiest way I found to do this is with the following command.
nohup java -jar path/to/jar.jar &
This ensures the jar will run as a background process.

Run war file on localhost without having tomcat installed

Is there any way to run a war file on localhost without having the need to have tomcat installed on the machine? I have built a web application using gradle, spring and tomcat and I would like to be able to send the project as a war file to someone else and have them run it, even if they don't have tomcat installed.
Make it a runnable jar which contains tomcat inside. And then start the application with:
java -jar myWebApplication.jar
https://www.baeldung.com/deployable-fat-jar-spring-boot

How to set up java runtime environment in online server

Actually I have to run my java war file having service which i want to access .normally in pc we run eclipse and use tomcat to do so. But in server if I have space then how to run my war file over there.
Basically you just install tomcat on your server and deploy the war file to it. There is lots of documentation on how to do this.
I would turn to the tomcat documentation on how to get started:
https://tomcat.apache.org/tomcat-8.0-doc/introduction.html

Deploy web app java project that self installs tomcat

how to deploy a web app java project which depends on tomcat and Sql Server Compact Edition (SqlCE) ?
so that the final user can only install the .jar (I don't know if it can be an .exe or not) and the setup takes care of installing tomcat (portable edition?) and SqlCE
I guess you have two options:
Use components written in java (for instance: embedded jetty as a web server, HSQLDB as a database). Then you can ship your whole application as a JAR archive (or few JARS) and create batch script which will run it (.bat under Windows, .sh under Linux or even .exe installator of some sort). This, however, might require some additional work.
Use some sort of EXE instalator wizard which will: 1. Install Tomcat into specified directory, 2. Install your desired DB, 3. Copy your webapp WAR inside newly created Tomcat installation
I would go for 1, since it will work on every OS.

I want to run a bash script when Tomcat deploys my web application from its .war file - is this possible?

(Tomcat version 5.5, in case it matters.)
I have a library in one of my web applications that needs to be configured with a machine-specific license before use. I don't want to put this library in shared/lib because at some point I may want to run multiple web applications with different versions of the library.
Right now the .jar files are stored in WEB-INF/lib. Thus, when I build the .war file and upload it to the server, the .jar file would still be the one bound to my PC. I would like to put a bash script somewhere in the webapp that Tomcat would automatically run when deploying the .war file - this script would then run the configuration script and bind the server's license file to the .jar. Is this possible? Is there a nicer way of doing what I want?
You could create a ServletContextListener to do that in the contextInitialized() method. And from that listener you can run the "configuration script" directly, no other script required.

Categories