Page 1 of 2 12 LastLast
Results 1 to 20 of 36
  1. #1
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Question Jar doesn't work

    Good morning.

    I have a problem with the construction of a Jar of a program I have. I make it with "Clean and build Main Project" in netbeans 7.0, then it creates the "dist" folder and into a jar and a readme. The jar does nothing, the cursor becomes a moment to fleach with the clock, but ends up doing nothing. What can happen?


    Thank you very much.

  2. #2
    Mr Oatman's Avatar
    Mr Oatman is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    I guess your program only uses console as input/output?
    Try to run the jar from a batch file:
    Java Code:
    java -jar MyJarFile
    pause
    Last edited by Mr Oatman; 08-04-2011 at 07:55 PM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    Console application or GUI?

    db

  4. #4
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    GUI with swing. I'm sorry

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Try to execute it in a command prompt window:
    java -jar <YOURJARFILENAME>.jar
    Copy the console window here.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

  6. #6
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    Microsoft Windows [Versión 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. Reservados todos los derechos.

    C:\Users\Administrador>prompt window:

    window:java -jar Estaticos.jar
    Error: Unable to access jarfile Estaticos.jar

    window:

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,953
    Rep Power
    19

    Default

    Is that where your jar file is located?
    You need to do that command in the directory containing your jar file.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Use the dir command to display the contents of the directory you are in to make sure the jar is there

  9. #9
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    This is the correct lines:

    Microsoft Windows [Versión 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. Reservados todos los derechos.

    C:\Users\Administrador>cd dist

    C:\Users\Administrador\dist>prompt window:

    window:java -jar Esta.jar
    Exception in thread "main" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at esta.Interfaz.<init>(Interfaz.java:63)
    at esta.Esta.main(Esta.java:8)

    window:

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    So now you've got a different problem entirely, a NPE. Time to do some debugging. First find out where the error is (line 63 in esta.Interfaz, next find out what objects you're trying to dereference on that line.

  11. #11
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    my line 63 is: botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Cerrar.png")));
    that initializes a JButton

    and

    the line 8 is:

    Java Code:
    1 
    2  package esta;
    3
    4  public class Esta
    5     {
    6    public static void main(String[] args) 
    7         {
    8         Interfaz inter = new Interfaz();
    9         inter.Comienza();
    10        }
    11   }
    in "Interfaz" I make all the graphic part whit other classes.

  12. #12
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    When I clic on "Clean and build Project", on the output window appears this:

    init:
    deps-clean:
    Updating property file: D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\built-clean.properties
    Deleting directory D:\Documentos\Descargas\NetBeansProjects\Esta\buil d
    clean:
    init:
    deps-jar:
    Created dir: D:\Documentos\Descargas\NetBeansProjects\Esta\buil d
    Updating property file: D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\built-jar.properties
    Created dir: D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\classes
    Created dir: D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\empty
    Created dir: D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\generated-sources\ap-source-output
    Compiling 5 source files to D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\classes
    warning: [options] bootstrap class path not set in conjunction with -source 1.6
    Note: D:\Documentos\Descargas\NetBeansProjects\Esta\src\ esta\Interfaz.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 warning
    Copying 11 files to D:\Documentos\Descargas\NetBeansProjects\Esta\buil d\classes
    compile:
    Created dir: D:\Documentos\Descargas\NetBeansProjects\Esta\dist
    Copying 1 file to D:\Documentos\Descargas\NetBeansProjects\Esta\buil d
    Nothing to copy.
    Building jar: D:\Documentos\Descargas\NetBeansProjects\Esta\dist \Esta.jar
    To run this application from the command line without Ant, try:
    java -jar "D:\Documentos\Descargas\NetBeansProjects\Esta\dis t\Esta.jar"
    jar:
    BUILD SUCCESSFUL (total time: 0 seconds)

  13. #13
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    mmmm caramba! I find that the error in this line:

    Java Code:
    botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Guardar.png")));
    is anything about the image I use to put to that JButton. I put the same image forn the otre JButton I use in this code, and the JAR runs! but the image I need add to this button does not!
    Last edited by Fubarable; 08-06-2011 at 04:43 PM. Reason: language cleaned up

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    I put the same image forn the otre JButton I use in this code, and the JAR runs!
    That would mean that your code is good, now you must Make sure the image exists in the folder and that you have spelled its name correctly.

  15. #15
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    But the code works when I run it from netbeans, the icon apears, but in the jar does not. The image exists and the name in the code is correctly.

  16. #16
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mad72584 View Post
    The image exists....
    But is the image in the Jar file and in the correct location relative to the class files?

    Also, please watch your language. I have edited a post above to remove some foul language.

  17. #17
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    I'm so sorry couse my word, I did no mean bad words, only it was a expression but I know I don't have to use it.

    these are the lines:

    Java Code:
    59        botonGuardar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Guardar.png")));
    60        botonGuardar.setEnabled(false);
    61        botonImprimir = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Imprimir.png")));
    62        botonImprimir.setEnabled(false);
    63        botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Cerrar.png")));
    64        botonCerrar.setEnabled(false);
    65        botonAyuda = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Ayuda.png")));
    the line 63 is which has problem, and the file "Cerrar.png" exists whit the identical characteristics than other images.

    When I change the line 63:
    Java Code:
    63        botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Cerrar.png")));
    for this one:

    Java Code:
    botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Guardar.png")));
    the jar works and ofcourse with tow buttons with the same icon.

  18. #18
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Is the Cerrar.png image present in the Jar file in the /Imagenes/ directory? The Guardar.png is certainly there, but I have to wonder about the "close" image.

  19. #19
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    The image exists the same way than the other files (images): the same location, the same kind file, the only defference is the name.

    And can you explain this part?:

    The Guardar.png is certainly there, but I have to wonder about the "close" image.
    I don't understand what you mean. Excuse me.

  20. #20
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What I mean is, have you inspected the jar file to see that the close/cerrar image is in fact present, that it is not corrupted.

Page 1 of 2 12 LastLast

Similar Threads

  1. why this doesn't work?
    By hitesh_public in forum New To Java
    Replies: 5
    Last Post: 08-09-2010, 08:07 AM
  2. JScrollPane doesn't work?
    By ecliptical in forum New To Java
    Replies: 4
    Last Post: 01-25-2010, 12:35 AM
  3. Why doesn't this work?
    By Corder10 in forum New To Java
    Replies: 1
    Last Post: 07-04-2009, 10:33 PM
  4. my loop doesn't work.. pls help???
    By ashton in forum New To Java
    Replies: 5
    Last Post: 01-16-2009, 08:24 AM
  5. Synchronization Doesn't seem to work
    By sherinpearl in forum Threads and Synchronization
    Replies: 1
    Last Post: 04-23-2008, 06:30 PM

Tags for this Thread

Posting Permissions

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