Executable Jar File
#1
Posted 19 March 2005 - 09:47 PM
Perhaps a button when clicked , asks which is the main class to execute ( if this cant be auto-detected ) , and packages it up.
I realise there is a usertool for making it into a normal jar file, but this doesnt make it executable unfortunately.
a feature to allow jar file signing would also be appreciated
#2
Posted 19 March 2005 - 10:10 PM
click:
Configure>Options>Tools>New>Create JAR File
this creates an user tool to create a JAR file, this does not yet include the manifest, you will have to manually add the manifest.
OR you can configure the command line switches to incorporate the manifest, try this for example:
cvmf $[PrjDir]\MANIFEST.MF $[PrjName].jar .
this should include the manifest 'MANIFEST.MF' in your project directory as a manifest. You will have to create that yourself though.
NOTE: this has NOT been tested
Though I do agree that an automated way of creating executable JAR files are a good improvement on the current feature set.
#3
Posted 21 March 2005 - 10:57 AM
#4
Posted 05 April 2005 - 04:32 PM
I tested it, it worked with just a minor modification though:
cvmf "$[PrjDir]\MANIFEST.MF" $[PrjName].jar .
before I added the quotes, the $[PrjDir]\MAINFEST.MF turned to be c:\documents;
after adding the quotes, the full path was included.
Thanks
#5
Posted 05 April 2005 - 04:50 PM
#7
Posted 06 April 2005 - 03:22 PM
#8
Posted 06 April 2005 - 07:42 PM
I'm sure Xinox is going to include this in JCreator v. 4.0 - I'd be very concerned if it turned out otherwise.
lordSaurontheGreat@gmail.com
JDK 6 Documentation - READ IT! LOVE IT! LIVE IT!
THOU SHALT GOOGLE BEFORE POSING THY QUERY!
If you're reading this you have given me control of your mind.
Why do accesses to your mind throw a "null pointer exception?"
#9
Posted 06 April 2005 - 08:47 PM
I'm sure Xinox is going to include this in JCreator v. 4.0 - I'd be very concerned if it turned out otherwise.
i hope they do it in a 3.x release or i`ll have to buy it again :(
im only a poor lil student you know! :)
#10
Posted 20 September 2005 - 01:10 AM
but what is actially in the manifest file?
#11
Posted 20 September 2005 - 06:52 AM
Created-By: 1.5.0_04 (Sun Microsystems Inc.)
Main-Class: RC5Gui.RC5StatsFrame
for more info, read this: http://java.sun.com/j2se/1.5.0/docs/guide/...#JAR%20Manifest
#12
Posted 01 October 2007 - 09:40 PM
"Could not find the main class. Program will now exit."
I think it deals with the manifest but i am confused on how to fix it.
edit: Ok, i got it to work but i am having a new problem now. My program uses pictures and I would like those to be included in the jar file instead of the pictures having to be in the folder with the jar. Is there a way to do this?
#13
Posted 01 October 2007 - 10:20 PM
import java.awt.Image;
import java.awt.MediaTracker;
import java.net.URL;
import javax.swing.ImageIcon;
/**
This is a utility class that allows images to be loaded from file, from a URL, or
from a JAR file.<p>
COPYRIGHT (C) 2007 ham90mack. All Rights Reserved.
@author ham90mack
@version 1.20 2007-06-22
*/
public class ImageRetriever
{
/**
This class is a utility and should never be constructed.
*/
private ImageRetriever(){}
/**
Retrieves an ImageIcon from file. This method first tries to get the image from
the base folder that is defines when starting the JVM. If the image is not found,
then this attempts to get the image from a folder named "images". If the image is
not found, then this attempts to load the image from a URL. If the image is not
found or if the String is not a valid URL, then this attempts to load the image from
the JAR file this may be in. Note that if an image is expected to be in a folder within
the jar file named images, "/images/" does not need to be provided. Otherwise, make sure
to put "/" at the beginning of the filename. If the image is not found, a RuntimeException
is thrown.
@param filename the image file to retrieve
@return the ImageIcon created from the file
@throws RuntimeException if the icon does not exist
@see #getImage(String)
*/
public static ImageIcon getImageIcon(String filename)
{
// to read from file
ImageIcon icon = new ImageIcon(filename);
//checks if the icon is in a folder named images
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)){
icon = new ImageIcon("images/" + filename);
}
// try to read from URL
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) {
try {
URL url = new URL(filename);
icon = new ImageIcon(url);
} catch (Exception e) { /* not a url */ }
}
// in case file is inside a .jar
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) {
URL url = ImageRetriever.class.getResource(filename);
if (url == null) throw new RuntimeException("image " + filename + " not found");
icon = new ImageIcon(url);
}
return icon;
}
/**
Retrieves an Image from a file. Calls getImageIcon to get the image and returns the
Image within the ImageIcon.
@param filename the image file to retrieve
@return the Image created from the file
@throws RuntimeException if the icon does not exist
@see #getImageIcon(String)
*/
public static Image getImage(String filename)
{
ImageIcon icon = getImageIcon(filename);
return icon.getImage();
}
}
NOTE: when adding this class to your project, make sure to import the package "images" in whatever java files need to use these methods.
http://ham90mack.googlepages.com
Resistance may be futile,
But capacitance has potential.
BLAH!
#14
Posted 02 October 2007 - 12:25 AM
#15
Posted 02 October 2007 - 12:57 AM
"import images.*;"
and you will be fine! That is what package structure is for; it allows related libraries to be grouped together, but you do not need to adapt to their structure.
http://ham90mack.googlepages.com
Resistance may be futile,
But capacitance has potential.
BLAH!
#16
Posted 02 October 2007 - 01:48 AM
#17
Posted 08 April 2008 - 09:23 PM
Download Create Manifest Batch File and install it to JCreator dir.
Here it is how it look:












