0

I did a Web Application using Netbeans IDE 8.0 in JAVA platform. The project consists of JSP's, Servlets and normal .java files. I would like to deploy the project as a simple jar file to the client so that they can execute the jar file and use the application. I am trying to generate jar file using Netbeans with the given resources but there were no proper resources for this. When I tried one of the sources provided, a war file is created rather than a jar file.

So, please help me in converting my web application into a jar file. Also, please let me know why a war file is created for my application rather than a jar file. Also, let me know how to execute war file.

VAMSHI PAIDIMARRI
  • 236
  • 1
  • 4
  • 9
  • First of all a web application is mostly exported as a war. So you can use the war to deploy on client server. – Bilbo Baggins May 14 '14 at 07:11
  • I'm not sure you understand what you are asking. I'm not convinced you understand the difference between a server side web application and a client side desktop application. Of course you can package a war file into a jar file with an embedded webserver, but I don't think that is what you want to do. – Boris the Spider May 14 '14 at 07:13
  • http://stackoverflow.com/questions/5871053/java-war-vs-jar-what-is-the-difference – Perneel May 14 '14 at 07:14

1 Answers1

1

Java applications use jar files and java web-applications use war files. JAR (Java ARchive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file to distribute application software or libraries on the Java platform. WAR file (Web application ARchive) is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application. Since the structure of a web application is very much different from a typical java standalone application you need to deploy it into a war file. To run a WAR file you need a java EE based server like apache tomcat, jboss, glassfish etc. Steps required to run the war file are (One of the solutions possible, although there are many other -as pointed out by boris):-

1.Start the web server;

2.Deploy the war file to the web server;

3.Visit JSP pages or servlets in the browser by entering thier links to their path.

see this link for more details on deploying war :- deploy war file in tomcat server

Community
  • 1
  • 1
Mustafa sabir
  • 4,130
  • 1
  • 19
  • 28
  • As I pointed out to another (now deleted) answer, whilst this is strictly speaking true is it very unhelpful. There are thousands of examples of applications with embedded webservers. You can include a `Main` class in your `war` and simply bootstrap an embedded server instance. With something like Spring Boot this is two lines of code. So those steps are not _required_, they are just one way of running a war file. – Boris the Spider May 14 '14 at 07:41
  • True, but i have tried to point out the most simplest and typically used solution possible to his question "Also, let me know how to execute war file". If his question were "Also, let me know how to execute war file in all possible ways" i would have pointed out others too. And this was not the only question asked so had to focus on others too. One could write articles on just "what is jar/war". Also edited and added link to detailed description of deploying war file. – Mustafa sabir May 14 '14 at 08:04
  • I got to know that a war file is generated for any web application. I got a war file. But the thing is that I was unable to execute that war file. Could you please help me? – VAMSHI PAIDIMARRI May 14 '14 at 12:16
  • War files can be deployed (and run) on server , see my answer there is a link which tells how to deploy a war on apache tomcat server. – Mustafa sabir May 14 '14 at 12:52