Question

I am using windows 7.
I have written a simple Spring3 Hello World using Eclipse and successfully run it using tomcat on my computer.
Now I have a Server which runs Linux.
I would like to run the project that I just wrote on my server. It has no GUI or anything of the kind so I can't simply start up eclipse and write the same project on the server.
How do I go about doing that? I am completely new to the whole java and Spring thing, and have absolutely no clue as to how to run my project on the server and be able to view it.
I have searched everywhere online trying to figure out how to put my project on the Server, but it seems like Spring isn't the most noob friendly, especially with its documentation. There doesn't seem to be any explanation on how to take your code from one computer and put it into another and make it work.

Was it helpful?

Solution

There doesn't seem to be any explanation on how to take your code from one computer and put it into another and make it work.

That's right, as it is not often considered "not a programmers job". Its not very related to the framework you're using (Java EE or Spring or whatsoever), instead it's more of an infrastructure thing (related to the operating system and application server that are being used). Nevertheless, it can be very useful to know how the process works.

Generally speaking there are two steps:

  1. Packaging - If you use Maven, you simply run the mvn package command. Or using Eclipse, you can export your project as an WAR-file (Right-click your project, click Export, search for "WAR"). I would advice to use Maven, but that's a bit outside the scope of your question probably. Either way, this step will result in a WAR file.
  2. Deployment - This is a bit harder. The WAR file from step 1 needs to be copied to the Linux server where the application must be ran, and then copied into a special directory where the application server looks for apps. If you're using Tomcat on the Linux machine as well, look for the Tomcat installation directory and find the 'webapps' subdirectory. Other application servers have other procedures / locations, though.

This is under the assumption that Tomcat was already set up for you on the Linux server, and that is running.

OTHER TIPS

This has nothing to do with Spring and everything to do with packaging your application and deploying it in a Servlet container/HTTP server.

  1. Setup Apache and Tomcat (or some other servlet container) on your linux server.
  2. Package your Spring application as a war file (either with maven, ant, Eclipse, or some other build tool).
  3. Drop the war file in the /webapps directory of your Tomcat installation.
  4. Start Tomcat.
  1. Well first you need to get tomcat 'http://tomcat.apache.org/download-70.cgi', and set it up on the linux server you are trying to deploy to.

  2. Then you would export your project as a .war archive in eclipse (File -> Export -> war)

  3. Copy the war file to your server, and copy it into TOMCAT_HOME/webapps

  4. Start up tomcat and you should be able to access the application under localhost:8080/{APPNAME}, so if your war name is myapp.war the url will be localhost:8080/myapp

good luck!

Spring is just a 3rd party open source API. You can do without Spring and still be able to "run" your application on a server.

By "run", this means that your project must be placed in a directory in the server's filesystem, most of the time in the form of a WAR file.

I said most of the time, because if done correctly, you can actually put your project directory inside the server, and it will run without transferring it as a WAR file.

A WAR file is just an archive that has a standard directory structure so that it is readable and executable by the server.

Read the following link on how to package your project as a WAR:

http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Fcwwarovr.html

And then just copy the WAR file to the TOMCAT_HOME/webapps folder.

Packaging

cd c:/my_project_directory/Web/

jar cvf web-archive-test.war .

Deployment

cd c:/my_project_directory/Web/

scp *.war your_username@remote_linux_host:/some/remote_directory_where_tomcat_is_installed/webapps/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top