Results 1 to 20 of 20
Thread: Regarding jar files
- 10-04-2008, 11:26 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
Regarding jar files
i am done making jar files, i also included the images that is needed for my GUI, how come that when i run my program on other Computer, my images cannot be displayed? the only thing displayed is the GUI itself even the button images that i assigned didn't work, i included them in my codes and i also included them when i packaged the jar file, what should i do about this? please help me,,:)
thanks,
- 10-04-2008, 02:39 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You say that when you run the jar package it's working fine. But in different PC it's not, images only is missing.
Try this, on the second machine extract your jar file. Then try to run your same jar file which you try to run before. I'm sure it's work.
- 10-04-2008, 02:40 PM #3
How is your code reading the image files? From the jar or from the disk? Do you use a getResource method or a File class method?
The File class doesn't work to read from a jar file.
- 10-05-2008, 07:08 PM #4
Member
- Join Date
- Oct 2008
- Posts
- 68
- Rep Power
- 0
make sure the images are part of your jar file....
- 10-06-2008, 08:43 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 10-06-2008, 11:46 AM #6
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
i used a code wherein i access image file through the disk which is particularly stored in my C:,,, the problem is that when i move that image , it will not be displayed,,, the first thing i've done is that i included that file in my jar compilation,, should i extract the jar file in every computer where i will distribute my program? isn't it kinda odd? is there a way to make things much easier for my firends?
thanks for the reply guys
- 10-06-2008, 11:48 AM #7
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
for priyanka,,,,,
the images are part of my jar file..
- 10-06-2008, 01:48 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 10-06-2008, 02:27 PM #9
If you put all the resources (like images) your program needs in the jar file, you will be able to access/read them in the program that runs from the jar file. The trick is to use the getResource methods to access the files in the jar NOT the File classes.
There are code examples on this forum on how to use getResource methods to read files.
- 10-06-2008, 02:55 PM #10
Member
- Join Date
- Sep 2008
- Posts
- 36
- Rep Power
- 0
Whoa, Norm that's a nice tip... *Puts in permanent memory*
- 10-07-2008, 01:29 PM #11
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
guys, the situation i am in ryt now is like this,, i declared an ImageIcon for my label, but wen i compiled it in the jar the label dont't have imageIcon anymore, i am puzzled because i included my image file in my jar...any suggestion guys?
- 10-07-2008, 01:31 PM #12
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
i also have a problem regarding memory usage..(CPU Memory).. when i exit my program thru clicking the close button, the process doesn't end, i discovered it when i view the task manager, and then the process for my application is still there,, i included a windowDistroyer in my program but still the closed program still access memory..any idea guys?
- 10-07-2008, 02:09 PM #13
Your app can close its windows and stay running without GUI. To exit the app, call System.exit(). Also the JFrame class has a method call (setDefault...) that will exit the app when the frame is closed.
- 10-08-2008, 04:32 AM #14
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
Norm,, i did included System.exit() in my program,, but i did this
System.exit(0);
is there any difference with
System.exit();
i think it requires an int.. isn't it?
- 10-08-2008, 02:49 PM #15
Yes.
Its always best to read the API doc when using methods you are not sure of. I don't always type correct java and try not to give completely correct answers to cause you to have to look them up.
- 10-09-2008, 07:38 AM #16
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
ok,, i got it.. i'll try to modify my program to see if there will be a change..
- 10-09-2008, 07:46 AM #17
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
norm here is the fragment of my code, hope you make a comment out of this,,
public static void main (String [] args)
{
up2 m = new up2();
m.setVisible(true);
m.addWindowListener(new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
System.exit(0);
}
}
);
}
tha'ts my main method, but if i close my GUI,, the process is still there,, it won't end even if i included the code above..
- 10-09-2008, 02:09 PM #18
What object type is m/up2? Is the listener called? Put a println() before the System.exit. I'd bet it is not being called.
Use the @Override statement before any method call being overriden in an adapter class. There won't be a compiler error if you misspell the method name and don't use @Override.
- 10-10-2008, 05:00 AM #19
Member
- Join Date
- Oct 2008
- Posts
- 31
- Rep Power
- 0
ok i got it,, i'll try your suggesstion, anyway, the m is an object of the class up2, up2 is the name of my class that inherits the JFrame...
- 10-10-2008, 07:50 AM #20
Similar Threads
-
Behaving text files like binary files
By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM -
Writing to files within jar files
By erhart in forum Advanced JavaReplies: 0Last Post: 02-04-2008, 02:50 AM -
Text and image files within jar files
By erhart in forum Advanced JavaReplies: 8Last Post: 01-19-2008, 04:43 AM -
how to convert mpeg files to .wav files
By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 04:14 AM -
convert xls files into pdf files
By bbq in forum New To JavaReplies: 3Last Post: 07-20-2007, 03:56 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks