Results 1 to 5 of 5
  1. #1
    turkerc is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default 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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default 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.

    ** This space for rent **

  3. #3
    turkerc is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default 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.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default 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.

    ** This space for rent **

  5. #5
    turkerc is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default 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

  1. How to upload files into ms access using jsp in netbeans 7.0.1... :)
    By mervinshe in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-08-2012, 02:45 PM
  2. Compile two files together through NetBeans
    By atiprashant in forum New To Java
    Replies: 5
    Last Post: 05-21-2011, 08:48 AM
  3. Questions about jar files / netbeans
    By trishtren in forum NetBeans
    Replies: 9
    Last Post: 04-28-2011, 12:21 PM
  4. Import files from NetBeans
    By Juuno in forum Eclipse
    Replies: 2
    Last Post: 04-08-2009, 05:20 AM
  5. how to make installation files using netbeans 6.5
    By santhosh_el in forum AWT / Swing
    Replies: 1
    Last Post: 03-25-2009, 11:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •