Results 1 to 20 of 36
Thread: Jar doesn't work
- 08-04-2011, 06:53 PM #1
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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.
- 08-04-2011, 07:35 PM #2
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.
- 08-04-2011, 07:37 PM #3
Console application or GUI?
db
- 08-05-2011, 01:36 AM #4
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
GUI with swing. I'm sorry
- 08-05-2011, 02:36 AM #5
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.
- 08-05-2011, 05:05 AM #6
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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:
- 08-05-2011, 10:46 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Is that where your jar file is located?
You need to do that command in the directory containing your jar file.
- 08-05-2011, 01:17 PM #8
Use the dir command to display the contents of the directory you are in to make sure the jar is there
- 08-06-2011, 05:01 AM #9
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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:
-
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.
- 08-06-2011, 05:17 AM #11
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
my line 63 is: botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Cerrar.png")));
that initializes a JButton
and
the line 8 is:
in "Interfaz" I make all the graphic part whit other classes.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 }
- 08-06-2011, 05:23 AM #12
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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)
- 08-06-2011, 05:57 AM #13
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
mmmm caramba! I find that the error in this line:
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!Java Code:botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Guardar.png")));Last edited by Fubarable; 08-06-2011 at 04:43 PM. Reason: language cleaned up
- 08-06-2011, 02:02 PM #14
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.I put the same image forn the otre JButton I use in this code, and the JAR runs!
- 08-06-2011, 04:37 PM #15
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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.
-
- 08-06-2011, 07:24 PM #17
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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.
.gif)
these are the lines:
the line 63 is which has problem, and the file "Cerrar.png" exists whit the identical characteristics than other images.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")));
When I change the line 63:
for this one:Java Code:63 botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Cerrar.png")));
the jar works and ofcourse with tow buttons with the same icon.Java Code:botonCerrar = new JButton(new ImageIcon(getClass().getResource("/Imágenes/Guardar.png")));
-
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.
- 08-06-2011, 08:14 PM #19
Member
- Join Date
- Aug 2011
- Location
- Bogotá
- Posts
- 28
- Rep Power
- 0
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?:
I don't understand what you mean. Excuse me.The Guardar.png is certainly there, but I have to wonder about the "close" image.
-
Similar Threads
-
why this doesn't work?
By hitesh_public in forum New To JavaReplies: 5Last Post: 08-09-2010, 08:07 AM -
JScrollPane doesn't work?
By ecliptical in forum New To JavaReplies: 4Last Post: 01-25-2010, 12:35 AM -
Why doesn't this work?
By Corder10 in forum New To JavaReplies: 1Last Post: 07-04-2009, 10:33 PM -
my loop doesn't work.. pls help???
By ashton in forum New To JavaReplies: 5Last Post: 01-16-2009, 08:24 AM -
Synchronization Doesn't seem to work
By sherinpearl in forum Threads and SynchronizationReplies: 1Last Post: 04-23-2008, 06:30 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks