Results 1 to 7 of 7
  1. #1
    linkingabo is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Help plz: not completely working JAR

    Hey all! I am new here and so to NetBeans and Java.

    I have a problem.. we had to write a little software in Java using NetBeans. For the GUI I used the AWT and SWING libraries.
    The software works perfectly in NB, but when I click on "Clean and Build project" and my JAR file is created it doesnt work the same as it did in NB.

    It is a software that generates an image from 1 to 16 different pattern images that the user can choose in the beginning and also the order of drawing the pictures into the final image.

    My JAR probably failes at generating the pictures.. or maybe even earlier. The GUI works, but the program does not.

    I even tried to add to my project all the possible libraries my NB has, but still nothing.. ://

    Could anyone please tell me how to solve this?

    EDIT: I am using NetBeans IDE 7.1 and
    Java: 1.6.0_16; Java HotSpot(TM) Client VM 14.2-b01

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,013
    Rep Power
    10

    Default Re: Help plz: not completely working JAR

    I'm not really sure what you want us to do with the information you provided. Add some print statements to figure out where your jar fails. You're going to have to be a lot more specific, and post an SSCCE that demonstrates what you're talking about, if you want to receive our help.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    linkingabo is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: Help plz: not completely working JAR

    all I can do is give you the NetBeans project, the wrong JAR file and the short User Guide I wrote, so that you can see what is not working, because there are no error messages.. would you help me this way?

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

    Default Re: Help plz: not completely working JAR

    So you're getting your GUI?
    What is it about the GUI that is a wrong then?
    Is it that the images are not shoing up?

    If so, then show us the code that reads the images in, including any exception handling.

  5. #5
    linkingabo is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: Help plz: not completely working JAR

    well, I found out what is wrong.. my JAR file cannot find the way to the images I am using in some of the GUI's "functions" (by clicking on some buttons).

    In the very beginning of my program, when it starts, XY miliseconds before opening my GUI, it copies the images I am working with from a directory named "combi4x4_resources", that is within another one named "Combi 4 x 4". The "Combi 4 x 4" is on my desktop, so the directories´ architecture is:::

    - Desktop
    -- Combi 4 x 4
    --- combi4x4_resources

    I am loading in 26 images into an array of Files (= imgFiles[]), than copy the images from that array one by one into an array of BufferedImages (= imgs[]):

    ..I have userHome defined as:
    static String userHome = System.getProperty("user.home");
    ..it finds the way to my basic user directory.
    ..I named my images "1.png", "2.png", .. "26.png", so it is easier to load them in.

    Java Code:
    int k = 1;
    for(int i = 0; i < 26; i++) {
        imgFiles[i] = new File(userHome + "/desktop/Combi 4 x 4/combi4x4_resources/" + k + ".png");
        k++;
    }
            
    imgs = new BufferedImage[26];
    
    for(int i = 0; i < 26; i++) {
        try{                
            imgs[i] = ImageIO.read(imgFiles[i]);   
        } catch (IOException e) {
            System.out.print("Some IO error :// ");
          }
    }
    ..the code written above works in NetBeans, but does not in my JAR.


    I would like to ask whether there is a method for getting the current directory where my JAR file is, so I could use that when I am loading in my images, like:
    Java Code:
    ...
    imgFiles[i] = new File(currentDirectory + "/combi4x4_resources/" + k + ".png");
    ...
    ..or could you show me some lines I could use for getting the current directory?

  6. #6
    linkingabo is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: Help plz: not completely working JAR

    well.. I solved my problem :D, thank you for your help btw!!

    I used these:

    Java Code:
    static String curDir = System.getProperty("user.dir");
    
    ...
    imgFiles[i] = new File(curDir + "/res/" + k + ".png");
    ...

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Help plz: not completely working JAR

    Cross posted, and didn't have the courtesy to inform the other forum that the problem is solved
    https://forums.oracle.com/forums/thr...readID=2338360

    db

    edit And http://forums.netbeans.org/post-123385.html
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 3
    Last Post: 01-16-2012, 12:12 PM
  2. HELP!!! Completely confused on how to fix this program!!!
    By BeginnerJava in forum New To Java
    Replies: 17
    Last Post: 06-13-2011, 12:59 AM
  3. completely new
    By battosai16 in forum New To Java
    Replies: 1
    Last Post: 08-05-2010, 08:43 PM
  4. Completely new to Java problem
    By Seamo14 in forum New To Java
    Replies: 4
    Last Post: 10-09-2008, 01:50 PM
  5. I am completely stuck
    By jpnym15 in forum New To Java
    Replies: 2
    Last Post: 11-14-2007, 07:40 PM

Posting Permissions

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