Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jar / Manifest File Questions 2

Status
Not open for further replies.

k4ghg

Technical User
Dec 25, 2001
192
US
I have written a java application with several classes, that use two zip files in its Classpath. I tried to creat an exacutable jar file and am having problems. The JAR runs the main class, but does not recognize the Classpath files.

I tried two Manifest file and can not get the JAR to run:

File I:
Class-Main = main - Note: I did not use any
extensions or folder
Class-Path = Jarone.jar Jartwo.jar - Note: Use space
to delimte entries and no
folders.

File II:
Class-Main = folder/main
Class-Path = folder/Jarone.jar; folder/Jartwo.jar

Any help would be appreciated. Also, does anyone know of a Jar builder program? I found JARBUILDER, but it did not include all the class files in my jar. Thanks
 
This taken from '
Up until JDK 1.5, java.exe ignored this entry. Note the list is space-separated, not semicolon-separated as in the SET CLASSPATH=C:\;. Note also that only relative directories and jar names are permitted using / not \. You cannot use C:\. This classpath has to be platform-independent.

If you use -jar on the java.exe command line, java.exe will quietly ignore the set environment classpath and any -classpath or -cp command line options.
 
Hi Thanks for the suggestion. I am still using Java 1.4x and managed to get the Main Class to work, but the Class path does not recognize my Jar files.

I Used:

Main-Class = folder.main
Class-Path = folder.Jarone.jar folder.Jartwo.jar

Any suggestions/ideas?

Thanks
 
Class-Path = folder/Jarone.jar; folder/Jartwo.jar
here you use ';' - while you cite 'use space as delimiter' above.

Are you trying to create nested jars?
This isn't possible at all.
The classpath inside a jar refers to outer packages.


seeking a job as java-programmer in Berlin:
 
Thanks for getting back to me. I am new to java. Does "nested Jars" mean that if I have classes to utilize classes in the Jar files I can't use them? Do I need to first extract the files and them put everything in one jar?

I did discover one interesting thing. My program uses data files and I had to take them outside of the Jar to be recognized.

Thanks again. Ronnie

 
You can not use classes in a jar, which is in a jar again.

Well - you can, if you write your own classloader or like to use one of the specialized classloaders out there, to do so.
Normally you wouldn't.
Especially not, when new to java.

Using images or data-files in a jar is no big issue.
Code:
/** get image from .jar.
* @param owner the owning component, must be a class from the jar, because the jar is found via that class.
* @param urlname the name of the image, i.e.: images/demo.jpg (note: no leading slash!
*/
public static Image getImage (Object owner, String urlname)
{
	Image img = null;
	try
	{
		URL url = owner.getClass().getResource ("/" + urlname);
		img = Toolkit.getDefaultToolkit().getImage (url);
	}
	catch (NullPointerException npe)
	{
		System.err.println ("img not found ");
	}
	return img;
}

seeking a job as java-programmer in Berlin:
 
Thanks for the tip about the nested Jars. I tryed again, by decompressing the Jar and recreating a new Jar with all the classes. Its interesting that when I use only my classes the Jar runs upto a point and when I add the decompressed Jar it will not run.


Thanks.

Ronnie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top