Netbeans web application - excluding the JAR while building the WAR - netbeans

I'm using Netbeans IDE for developing a web applications, and I've some JARs available in the application server which don't need to be in the WAR (but we need them to compile and run locally).
Is there an option in Netbeans to exclude the JAR file while building the WAR file?

Select the project in the Projects explorer window.
Pick the Project Properties item from the File menu (up in the menubar).
Select the word Libraries from the list on the lefthand side of the dialog that appears.
For each jar/library listed in the Compile-time Libraries list, uncheck those that do not need to be included in your war file.

I found the problem myself. I've all the libraries under my lib folder and added them to the project class path. Since the build is copying the entire content in the project, my library is also copying even though I've unchecked the package check box against the library.
So, don't put the library in your lib folder if you want to exclude that in the WAR built.
Thanks
Santhosh

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.

Adding project dependency to web project in Eclipse

I have a Dynamic Web Project that gets deployed as a WAR that I have created in Eclipse. The project depends on 2 other small projects. I have them marked for export, and have them on the build path, but Eclipse warns me that it will not be exported, and sure enough, I get a ClassNotFoundException when I try to compile.
If need be, I can pull all the java files into a .zip file, but I don't know how to add a .zip file as a dependency. I'm sure I'm making this harder than it needs to be.
Open the web project's Properties dialog (context menu, or Project menu from the menu bar) and go to the Deployment Assembly page. This is where you tell it to also make them jars when deploying.

How to add a library to eclipse of .jar files that are NOT a "User Library"?

I am attempting to add a group of .jar files to my build path for a project that is under source control. Specifically I have downloaded the Smack API and I have a folder located in my project/libs/ that contains the multiple smack .jar files I will need.
If I go to Project > Properties... and try to use "Add Library..." under the "Libraries" tab. The only option that makes sense is to add an "User Library". However, this doesn't work with source control as User Libraries appear to be defined in the workspace/.metadata/ folder, and is not under source control.
I can add each .jar file using Project > Properties... using "Add JARs..." under the "Libraries" tab, but then each .jar shows up separately in the build path (not grouped neatly together like other system libraries). Between HAPI, HTTP Components, and Smack .jar's I need, the build path contains a lot of separate jar files and I just want to group them together.
Is this a limitation of Eclipse? Or am I missing something?
Here's the link from one of my Eclipse projects. Eclipse does not group them together - you just add each jar and get the list from this screen. To add libs that are in the project folder structure, use Add Jars..., for external jars, use Add External Jars...
As mentioned by #mikemil, add external jar is the way for non-web apps.
If your project is a web application and has a .../WEB-INF directory, you can put the jar in the .../WEB-INF/lib directory and it will be in the deployed WAR file as well as in the build path.

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.

how to setup the sphinx with netbeans

i have successfully configured sphinx4 with eclipse.
for that these steps i have used.
copy my java and config files to SRC folder
all the necessary jar files (in the lib). the lib folder added to the root of the project
build those jar files (jsapi files too)
change the configuration file and give the proper path
test the java file
but in Netbeans i really dont understand how to do the proper steps. can someone help me. the jar files should be added to "Libraries" rite.
then after adding them how to build them.
in the netbeans it dont show a SRC folder. so all the java files and configuration files should go to Source Packages folder rite.
can someone help me with this. please
If you have sphinx4-1.0beta6 then you can just open the folder up as a netbeans project. Open netbeans, click open project, then navigate to the sphinx folder and open it. It is already a netbeans project file type as of this version. I assume this will work in later versions also. I have no clue why sphinx doesn't say this on their website.
Sphinx4 is a Java library available in OSS repository, so you can use it as any library.
If your project uses maven/gradle, add repository in your project configuration, then add dependency on two packages - sphinx4 core and sphinx4-data. The former is the main library, the latter is required if you want to recognize US English. Then just start writing the code.
If you want to rely on jar files, just download sphinx4-core and sphinx4-data files from the repository and add them as dependency to the project, then start writing code.
If you want to modify or develop sphinx4 itself, install Gradle support in your IDE, then import latest sphinx4 sources as a Gradle project.
For more details and links see the tutorial
http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4
click on Add JAR/Folder
select jar file you want to add