Results 1 to 5 of 5
Thread: Netbeans and jar files
- 09-14-2012, 02:36 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 3
- Rep Power
- 0
Netbeans and jar files
I have ceated a java Application project in NetBeans. There are 3 source java files and there is an extra abc.class file inside a folder named xyz, which I added to the NetBeans project from Properties -> Libraries -> Add jar/folder (added the xyz folder). Every thing worked smoothly. Sucess!
Under the dist folder of the project a jar file was formed to operate the project .
I changed directory to dist and operated the jar file “java –jar file.jar”. There was an error. The class abc.class was not found.
So I have took all the .class files and formed up my own jar file manually. Using “jar –cf file.jar a.class b.class ....” then updated the manifest file to insert an entry for the main class. And run the jar file. Success!
So, what can be the reason for the failure in the second step, when I operate the jar file created automatically by NetBEans? The problem is that, the automatically formed jar file does not carry info about the extra class that I added under the Libraries in NetBeans. How can I make the lib-folder being known to the jar file that is created by NetBEans automatically?
There is no problem operating the project inside NetBEans. There is error when I try to operate the automatically created jar file. If I form up the jar file manually, there is no problem also.
- 09-14-2012, 02:56 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: Netbeans and jar files
I don't know how it handles class file dependencies by themselves.
With imported jar files it will put them in a lib directory in the dist directory, and the manifest will refer to them.
Is there anything else in the dist directory other than the jar file?Please do not ask for code as refusal often offends.
- 09-14-2012, 03:12 PM #3
Member
- Join Date
- Sep 2012
- Posts
- 3
- Rep Power
- 0
Re: Netbeans and jar files
The project folder structure is as follows:
build folder (classes, emty, generated-sources subfolders and built-jar.properties file)
dist folder (automatic created jar file and a reamme.txt file that describe build output and how to operate the jar file)
lib folder (my added folder that contains the extra class, copyLibs subfolder, and nblibraries.properties)
nbproject folder (...)
src folder (...)
built.xml file
manfest.mf file
that is all.
- 09-14-2012, 03:18 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: Netbeans and jar files
So it didn't transfer the class file into the dist folder.
Seems a bit of a flaw in the distribution logic, but then I suppose most people use jar files rather than importing individual classes.
There may be something in the Netbeans docs on how to get the class file included, either in the jar or in the dist directory...haven't got Netbeans here.Please do not ask for code as refusal often offends.
- 09-14-2012, 03:39 PM #5
Member
- Join Date
- Sep 2012
- Posts
- 3
- Rep Power
- 0
Re: Netbeans and jar files
Since there is an option Properties -> Libraries -> Add jar/folder, I had added the folder that included the extra class file. and it had worked. When I RUN the project inside NEtBeans, it successfully executed.
After you last warning, I have made a jar file file from the complete contents of the folder (my Lib) like jar cf myLib.jar *.class
And formed a new project using this new jar containing the extra class.
Now there is a Lib folder under dist and the jar for operating the project. The problem has been solved. Thank you Tolls, have a nice day...
Similar Threads
-
How to upload files into ms access using jsp in netbeans 7.0.1... :)
By mervinshe in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 01-08-2012, 02:45 PM -
Compile two files together through NetBeans
By atiprashant in forum New To JavaReplies: 5Last Post: 05-21-2011, 08:48 AM -
Questions about jar files / netbeans
By trishtren in forum NetBeansReplies: 9Last Post: 04-28-2011, 12:21 PM -
Import files from NetBeans
By Juuno in forum EclipseReplies: 2Last Post: 04-08-2009, 05:20 AM -
how to make installation files using netbeans 6.5
By santhosh_el in forum AWT / SwingReplies: 1Last Post: 03-25-2009, 11:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks