executable jar file

executable jar file not picking image

Page 1 of 1

5 Replies - 3540 Views - Last Post: 06 October 2010 - 01:23 PM Rate Topic: -----

#1 p.sinha4u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-September 10

executable jar file

Posted 06 October 2010 - 06:00 AM

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...

Is This A Good Question/Topic? 0
  • +

Replies To: executable jar file

#2 guido-granobles  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 171
  • View blog
  • Posts: 617
  • Joined: 02-December 09

Re: executable jar file

Posted 06 October 2010 - 06:09 AM

How is the path to the image in the java file?
Was This Post Helpful? 0
  • +
  • -

#3 p.sinha4u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-September 10

Re: executable jar file

Posted 06 October 2010 - 06:15 AM

this is in current directory.
Was This Post Helpful? 0
  • +
  • -

#4 guido-granobles  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 171
  • View blog
  • Posts: 617
  • Joined: 02-December 09

Re: executable jar file

Posted 06 October 2010 - 06:54 AM

Please post the code that you are using to load the image.
Was This Post Helpful? 0
  • +
  • -

#5 p.sinha4u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-September 10

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: :code:

This post has been edited by Dogstopper: 06 October 2010 - 01:21 PM

Was This Post Helpful? 0
  • +
  • -

#6 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,050
  • Joined: 15-July 08

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1