How do I deploy/import war package into Netbeans - netbeans

I have looked through the help documentation in netbeans 6.5.1 but cannot find anything explicit explaining how to deploy/import a war package.
I know in Eclipse, it's as easy as right clicking in the Project Explorer >> select IMPORT >> WAR FILE.
However, I still am unable to find a solution for Netbeans.
Thankyou,
Jordan

posted elsewhere, thought i might post here too.
after some googling I've found the solution and here are the steps:
(tested using apache's ode.war in NetBeans 8.0)
unzip the war file
in the unzipped folder, you will see WEB-INF/, META-INF/, etc., create a sub-folder named web in the unzipped folder.
put everything else into web (now they will be web/WEB-INF/, web/js/, ...)
go to netbeans, new project -> java web -> web application with existing sources
pretty much just press next all the way through. voilĂ , it's done.

I assume you don't already have an ant or maven project for your web project? If you did, you would just import a maven project or create a Web Free-Form Application and wire it up to your ant script.
I would unzip the war file, create a new web application with existing sources in netbeans and wire everything up using the wizard.

Import the war project to eclipse.
Then import the eclipse project to netbeans

If you don't have eclipse handy, just place the war file into the webapps folder of Tomcat, go to the bin folder of Tomcat and run startup. Tomcat will automatically extract the war file for you. Now go to the webapps folder and you'll find another folder there, with the same name as your war.
I couldn't find an option to import a war directly into Netbeans (strange. Perhaps someone could create this feature and submit it as a patch to Netbeans). The folder which gets extracted into the Tomcat folder can be used as the Netbeans project. It's advisable to copy it to some other folder first. Import by File > New Project > Web application with existing sources.
Eclipse has an option to export a war and include the sources with it too, so there's a chance that the source files are in the war too.

Related

deploy jar Java Desktop Application in jdeveloper12c

I have always developed my java NetBeans projects. When I finish my project, and automatically build "dist" folder where the main jar and a "lib" folder containing all the external jar was created. This is done automatically with the NetBeans IDE
Now I'm trying to do a project with jdeveloper 12c Java Desktop Application and try to deploy my project but I have problems with java.lang.NoClassDefFoundError. I meet several questions:
Can you add the same structure as I said before? That is, a file jar and inside a folder "lib" place the jars using How to do it?
I've seen examples that by New File Group adds refencias, but it really adds to the main jar file (as I see in the size of the file) but not saved in a separate folder.
I do not know if you can help me do this in jdeveloper 12c: Generate a jar file and folder lib with references.
Thank you for your help.
Go into the deployment profile for your project and add all the libraries and files that you need to be included to the JAR you are generating.

How to make war file of gwt project in eclipse?

I am making web application using GWT toolkit in eclipse and my application is running successfully as we run from eclipse to right click on project and select Run as web project.
But when i make war file from eclipse-ide to Right-click on the project, pick Export, then WAR file so it does'nt work.It give me error "enter module name" it does'nt detect automatically module name. it happens only when i make a web application with gwt plugin otherwise in simple web dynamic application war file create easily with eclipse ide.i want to know how to make a war file in eclipse? And how to deploy my gwt application with tomcat server?
Thanks
Rahul
Take a look to this other question: create a .war file from gwt-project
In fact the real answer will depend if you want to use ANT or Maven.
WAR files are just compressed version of your built web app projects. One simple way to make them is to use jar.exe in JDK package. That's enough to run this command after building your project in eclipse to compress those files as a WAR file:
jar -cvf name_of_jar_file.war -C /path-to-app-built-dir /path-to-put-jar-file
The best approach is to use the command
Export > Export ... > Web > War file
You will have this command on the context menu (right mouse button on the project folder) if you installed the Java tools for Web Applications. Otherwise that should you first step.
It may be the case that your GWT project doesn't show on the selector of the Web Project field, the first on on the dialogue box when you execute the command above. If this is the case you must make sure you have the Dynamic Web Module facet on you project. Select the project root project navigator and then execute
Properties > Project Facets
and check Dynamic Web Module on the right panel if it not already checked.
You should make sure that the WAR directory used by GWT is the same used by the dynamic web module. If you are not sure what is your WAR directory (probably it's the one named "war") you can go to
Properties > Google > Web Application
and read the content of the field WAR directory on the right panel.
Then make sure that the WAR directory is specified in the "Web Deployment Assembly". You need to go to
Properties > Web Deployment Assembly
and check if your WAR directory is listed there. If you war directory is "war" then you should have /war on one of the rows with the deploy
path /. Otherwise
press Add...
select Folder
press Next
select your WAR folder (e.g. war)
press Finish
If you fail to make your WAR directory part of your Web Deployment Assembly them the Export > Web > WAR command will create a WAR file, but it will lack the web.xml and all the static files on the WebContent folder, such as the HTML, images, etc.
Open your project.
Navigate to war folder.
Go to File>Export>Archive File
Export your war FOLDER as zip file.
Change your file extension form .zip to .war
Keep calm and enjoy your war file.

Deploy a War file with Eclipse and Tomcat 6 without a build file

I know there are a bunch of posts on this topic, but I can't seem to figure it out. Here is my setup:
- Eclipse Indigo
- Tomcat 6
- Struts WAR file that I imported into Eclipse from http://www.manning.com/dbrown/SampleApplication.zip
I added the server to Eclipse, and added the project to the server. It runs fine, but I'd like to make some changes to the XML and java files (not the jsp files). I was under the impression that Eclipse takes care of the deployment after I save and restart the server, but I guess this isn't the case. I looked into creating an ant file to do a custom build, but I'm not really sure how to make it since I don't even know how to do a deployment "manually". How would I go about doing a manual deployment? Thanks.
A war file is usually created by exporting it from an IDE like eclipse, netbeans, etc.
While generating a war file there is 2 options,
You can include your java files with it
You can avoid java files from it.
In both the cases class files will be there which are created from java files. Class files will be able to take care of the actions of java class.
If the war file which you down loaded is not having those java files, you will not be able to use it with eclipse, where as it will work fine if you are putting it into tomcat directory for running.
For running a war file manually just put it into tomcat webapps folder and run tomcat.
Then you can access the pages using the url.
http://localhost:8080/yourprojectname/
If you want to check whether the war file contains any java files, after starting the tomcat server it will extract the war file into the same directry, where you can search for java files.
If you want to run the project from eclipse,
import it into eclipse, open index.jsp page
right click-> run as-> run on server
if you have not yet configured the server yet,select the server in the list, specify its installation path, then add projects into server in next step, finish it. then it will load your project.
Please provide little more details so that we can help you better.
manual: copy the war in the tomcat folder then start tomcat.
if you want to use eclipse you need to click redeploy war first by right clickling the deployed war in the servers tab under tomcat.

How do you import a Java Class Library into a Java Web project (using NetBeans)?

I've already tried the options "Add folder...", "Add Library...", and "Add JAR/Folder...", but it's not working this time -- I've done this several times before without any problems.
I've also tried to add the folder / JAR file (.war-file) manually to the projects properties in every thinkable way, but still no success.
And so far, Google hasn't helped either..
Any help would really be appreciated.
(This is for a Java Web project with JavaServer Faces, using NetBeans 7.1)
Solved: I never found out what caused the problem. I ended up re-installing entire NetBeans, and re-created (a thousand times) the project I was trying to import. And in the end, I got it working.
Put the JAR file in the WEB-INF/lib directory of your web project. All JARs in the WEB-INF/lib and all packages in WEB-INF/classes are automatically in the CLASSPATH.
Can you make "Hello, servlet" work? If not, why bother with JSF? Do a simple web app successfully and build up from there.
I had this problem with netbeans, but it seems like all the answers I found are for Eclipse (I guess am wrong) as I dont see any WEB-INF/lib directoryin NetBeans, though I have a WEB-INF directory.
so here what I did.
I remove the tomcat server on NetBeans, go to C:\apache-tomcat-7.0.30\lib , put the jstl-1.2.jar file their, restart NetBeans and add a new (Tomcat) server, create a new web app, and their, I could find the jstl-1.2.jar file in the Libraries > Apache tomcat.
and for unknown reason, it worked.!

Export a web project

i have made a web application using java pages with eclipse.
But i have no idea how to export it for use?
I was asked to provide a make file or somehting, what other ways can i do this from eclipse?
It sounds like you need to export it as a WAR file:
Right-click the project in Eclipse
Choose Export
Choose WAR File
Just right click on the project and say export war.
There choose the appropriate server runtime for which you have created the project.
Then put that war file inside the webapps folder in case apache tomcat and restart the server.
And you have done. :)