War file creation with out eclipse - java

I am linux admin and i want to automate the process of java web application deployment process in my client location. And actually they are using svn tool for version control.
So my question is if they commit the​ code into subversion repository automatically create a war file through bash script and move that war file into tomcat for automated deployment....
This is my thought.. can u guys suggest me about war file creation remain process i can build through bash
Thank u in advance

To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file.
Go inside the project directory of your project (outside the WEB-INF), then write the following command:
jar -cvf projectname.war *
Here, -c is used to create file, -v to generate the verbose output and -f to specify the arhive file name.
The * (asterisk) symbol signifies that all the files of this directory (including sub directory).

There are multiple ways to create WAR file
Using ANT/Maven or many times framework also provides command e.g. Play Framework.
You basically need to go to the SVN checkout project folder.
if you have ANT or Maven project than follow the steps :
How to create a WAR file using the commandline?
How to create war files
else for other Java based project :
To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file.
Go inside the project directory of your project (outside the WEB-INF), then write the following command:
jar -cvf projectname.war *
https://www.javatpoint.com/war-file
You can then copy the newly created WAR file to Tomcat webapps folder using linux command
SCP or CP.

Related

Eclipse Java project: can I set eclipse to store .class and .java files in 1 folder?

I just need a simple environment of .class and .java files in a single folder so that I can execute java files later on using "java xx" in command line without adding any extra syntax. I'm not planning to use packages or sub-directories in my project and I won't be executing any files directly from eclipse either.
You could create a executable jar file and run it from command line using:
java -jar MyApplication.jar
Here is the link to create an executable jar file from eclipse:
How to create an Executable jar file
I think you are looking for this:
Create new project->Java Project->In the Project Layout section change to 'User project folder as root for sources and class files' (using Eclipse Kepler, it should be similar in other versions of Eclipse).
But keep in mind that it might become a mess after some time.

How to create Jar file with external folders and Jars

I made a simple standard-lone java Application using Spring,Apache Camel,Activemq for processing messages.
Note: My Application don't have any GUI.
My project structure is in the following way.
SACLib folder have nearly 70 external jars(all Spring,Camel and Activemq corresponding jars).
It's working fine in Eclipse. SO Now We want to deploy into Jar file.I tried in Eclipse,But I didn't seen Rod1,Rod2,Copy1 and SACLib folders in my Jarfile.
after Deploying Jar, If I run FirstConsumer.java it runs Rod1-->ThMapInfratab1-2.exe file. For this I mention Real paths of .exe file.
How can I make Jar file with including all my folders.
Thanks
Well, this is a kind of work that is typically done with build automation tools like Apache Ant, Maven or Gradle, so you can investigate there if you want to make this happen automatically next time.
But, if you want to do it manually...
First, you project needs a META-INF folder where you will place a file called a MANIFEST.
That manifest contains a Main-Class entry pointing to you main class. You can read about this in the Java Tutorial: Setting Application's Entry Point.
But it can also contain a Class-Path entry, pointing to all other jars required by your application and that should be loaded by the executable jar.
You can read about it the Java Tutorial: Adding Classes to your Jar Class Path.
If you are building your executable jar with Eclipse, it will let you choose the MANIFEST file that you want to use during the creation process.
Now, if you want to use build automation tools, there are other answers here that explain how to do it:
Creating a bundle jar with ant
How to create executable jar with dependencies with Maven
How to export an executable jar in Gradle
simply using ant download it , and then make a build.xml file and put it
Here's an simple example of an ant target that will create a jar (named test.jar) that includes all jar files under the lib directory. Maybe this will solve your problem?
for using apache ant, see this
http://ant.apache.org/manual/using.html

How to make jar file created by netbeans work from any location in the system

I have a java desktop application in netbeans. I have created an executable jar file for the project using clean and build command provided by the netbeans. By using this command the executable jar file gets created under netbeansProjects//dist/.jar. I am able to execute this jar file from command line using java -jar .jar from within project path. But the problem is that when i move this jar outside of netbeans projects folder, say to desktop and run the jar file, it is giving error of type "Exception in thread "main" java.lang.NoClassDefFoundError". How to solve this problem and make the jar file executable from any location of the system.
Complete instructions may be found in dist/README.TXT:
To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.
Ensure that the manifest inside of the jar file contains the necessary classpaths. If you are unfamiliar with the concept, go here: http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html
Netbeans has probably included any external projects/libraries/Jars in the dist/lib folder.
In order to run the application, you must include all the files in the dist folder when you copy the application
Check if in your projects Manifest.mf file has the Attribute
"Main-Class" set to your projects current main Class file.

Java RMI - jar on NetBeans

I have an RMI server that is using a class from another project. I have imported the jar of the other project as library on the RMI and it works fine on netbeans. Although when I run the RMI Server from the .jar generated by netbeans, I am getting classnotfoundexceptionfor the class imported.
Any suggestions why it would be running inside netbeans, but the jar isn't working?
Also I am not sure if it was the right choice but on the RMI I have checked " used dedicated library folder" since the other project is very small.
Also note I am importing the server on the other project too, so that it can use the remote interface.( although I guess this has nothing to do with the problem).
When you launch your rmi server you put in the classpath also the jar with the other class?
Try to launch the jar from command prompt:
java -jar -classpath rmiserver.jar:lib/other.jar rmiserver.jar
If you've built your project with a standard netbeans project (instead of a maven one), you'll see a lib directory underneath the dist directory where the final jar is built. Netbeans will build the manifest in the main jar file such that it will look for the dependent jars in that lib directory which is relative to the location of the built jar. So if you put your built jar in one directory, copy the lib folder to that directory, then launch it like so:
java -jar my.jar
e.g
+ folder
| my.jar
+-+ lib
| other.jar

How can I create a standalone Wicket executable?

I have created a Wicket application for a final year programming project. I need to create an executable version of this project. How can I do this in such a way that the person trying to execute the file need not have Wicket, any of its libraries or Tomcat to execute the file?
If you follow these instructions, you get a jar file which you can run like this:
java -jar selfcontained.jar
Build WAR file (mvn package on war packaged project if using maven).
Put it in /deploy directory of fresh Tomcat.
Wrap Tomcat including WAR with Tanuki Service Wrapper.
Give your customer ZIP file (or create GUI installer) and ask him to run a single script that install the service/deamon.
How were you working with your Wicket application so far?

Categories