i have made an application in which i am using a image file named "a.jpg", when i am running this program from command prompt ,it is showing the image properly.but when i creates a jar file for this , it does not show the image.
for making jar file first i have created a manifest.txt file which contents are following-
Manifest-Version: 1.0
Main-Class: SplashScreen
after that i created jar file from command prompt by typing following-
jar cvfm My.jar manifest.txt SplashScreen.class
problem is that jar file is created and it is working but not showing the image which i have included in this SplashScreen.java file.
plzz help me...
executable jar fileexecutable jar file not picking image
Page 1 of 1
5 Replies - 2668 Views - Last Post: 06 October 2010 - 01:23 PM
Replies To: executable jar file
#2
Re: executable jar file
Posted 06 October 2010 - 06:09 AM
How is the path to the image in the java file?
#3
Re: executable jar file
Posted 06 October 2010 - 06:15 AM
this is in current directory.
#4
Re: executable jar file
Posted 06 October 2010 - 06:54 AM
Please post the code that you are using to load the image.
#5
Re: executable jar file
Posted 06 October 2010 - 06:58 AM
import java.awt.*;
import javax.swing.*;
public class SplashScreen extends JWindow {
private int duration;
public SplashScreen(int d) {
duration = d;
}
// A simple little method to show a title screen in the center
// of the screen for the amount of time given in the constructor
public void showSplash() {
JPanel content = (JPanel)getContentPane();
content.setBackground(Color.white);
// Set the window's bounds, centering the window
int width = 450;
int height =350;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
// Build the splash screen
JLabel label = new JLabel(new ImageIcon("15.jpg"));
content.add(label, BorderLayout.CENTER);
// Display it
setVisible(true);
// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); } catch (Exception e) {}
setVisible(false);
}
public void showSplashAndExit() {
showSplash();
}
public static void main(String[] args) {
// Throw a nice little title page up on the screen first
SplashScreen splash = new SplashScreen(4000);
// Normally, we'd call splash.showSplash() and get on with the program.
// But, since this is only a test...
splash.showSplashAndExit();
}
}
Edited by Dogstopper:
This post has been edited by Dogstopper: 06 October 2010 - 01:21 PM
#6
Re: executable jar file
Posted 06 October 2010 - 01:23 PM
I have a tutorial dedicated to loading images:
http://www.dreaminco...part-1-loading/
What you will need to do is to stick the image in the JAR file as well and then use the code that I showed in my tutorial to load it.
http://www.dreaminco...part-1-loading/
What you will need to do is to stick the image in the JAR file as well and then use the code that I showed in my tutorial to load it.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|