I have been using it since version 3.x and it is currently version 6.1.
.jarContent
In version, 5 and below, it has its only proprietary way of compiling into jar file. It has a a binary file with the extension .jarContent. This file content contains all the information needed to build build and create the jar package.
Pro:
I am able have many java files in one folder and create multiple .jarcontent file to create different .jar application with it (by right clicking on the .jarContent file and select build jar).
Con:
I cannot build the .jar file without netbeans since the manifest file is with the .jarcontent file and I need a special editor to access it.
Ant
In Netbeans 6.0 was converted to use ant instead. This proved have its own challenges. One thing is migrating my old code to the new environment. One option is to create project from existing sources but this did not work very well with me because I was not able to put my folder in the right place.
A much easier way is to:
- Create a new Java Project.
- Create the package with the src folder.
- Copy the original code into the package folder. So for example the package is com.blogspot.programmersjournal, the folder will be src\com\blogspot\programmersjournal\ inside the project folder.
- build.xml (which is in the root folder of the project)
- nbproject folder (which contains the settings needed by netbeans).
- src folder (which contains the source code).
- dist folder is deleted and recreated when you do clean and build.
- libraries contains the .jar files you refer to.
- Test Package is when you want to do unit test.
Other Netbeans 6.x Info
When you create an application, the manifest file is automatically generated for you. However, when you create a library, the manifest file is not automatic. You will need to create it manually (as a blank file) and then add the line inside the project.properties file just after meta.inf.dir entry:
manifest.file=${src.dir}/manifest.mf
I always like to make sure there is a manifest file in all my jar files so that I can check on the version.
By default, if you add reference to other .jar files, netbeans will create a lib folder below the dist folder and put a copy of those .jar files there. At the same, time, it will add lib/... inside the manifest file.
You can override it by placing your own Class-Path: inside the manifest file then the NetBeans will not override it. I do this because I am used to putting my reference library in the parent folder rather then in the child folder.
A few additional things I like about Netbeans are:
- The plugins. It has a very rich library of plugins include UML, JavaFaces etc.
- You can easily switch between different versions of Java - by clicking Tools->Platform.
- It supports cvs, mecurial and subversion (Even though I use Visual SourceSafe in the office but I use subversion at home).
- Its intellisense is as good as the ones in Visual Studio.
- Formatting capability is good.
- It doesn't add reference to strange libraries. JDeveloper from Oracle does that when you create a windows application.
- With the new ant build, I have to create a different folder for each application project I am working on (even if it only contains one .java file.
- Loading is slow (it chews up a lot of memory), so not useful if your computer is slow.
- I have not been able to get the debugging to work correctly with line parameters. (it works fine without parameters).
2 comments:
I am not quite sure I understand how the manifest file works when creating a .jar in Netbeans. I have a project with multiple packages. Within my code, a relative path is given, but the .jar file does not seem to be able to access the file from the given path. Am I suppose to add the packages to the manifest file manually?
Thanks and your blogs are great!
Hi.
Class-path can be set in two ways:
1. by setting it at the OS level.
2. in the manifest.mf.
The class-path in the main .jar file will be used. The entries are case sensitive. An example of the classpath in my manifest path is as follows (all in one line):
Class-Path: ../JUtil2.jar ../classes12.jar ../ftp.jar
In the above example, all my other .jar files need to be in the parent folder the location of my main .jar file.
I hope this helps. Let me know if you need further assistance.
There are some write up on packaging at
http://java.sun.com/javase/6/docs/technotes/guides/extensions/spec.html
For detailed information of manifest file, see here:
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest
PS. Glad you like my blog.
Post a Comment