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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Spring with a JAR File

Status
Not open for further replies.

Ascalonian

Programmer
Jan 4, 2008
264
US
Using Eclipse, I setup a Java Project that uses the Spring framework. It runs successfully in Eclipse.

I need to create a JAR file of all the class files so I can move them to a server.

However, when I run the jar file using:
Code:
java -jar someName.jar org.com.companyName.TestThis

It complains that it cannot find the XML file that is needed.

How do I add the XML files to the CLASSPATH so that the JAR will recognize them?
 
I think (assume) the Spring framework needs an appserver (like JBoss, Glassfish, etc) with it's specific directory structure and installed infrastructure to be used. You won't be running it from a commandline then, though. But I may be wrong...

HTH
TonHu
 
The CLASSPATH is used to search for classes - not for any filetype else, afaik. Finding the file is a duty of your code.

You may use a self defined variable, to change that value at runtime:
Code:
java ... -Dsetupfile='/foo/bar/file.xml'
and
Code:
sFilename = getProperty ("setupfile")
see file:///$JAVA_HOME/docs/technotes/tools/solaris/java.html#options , Option -D and java.util.Properties


don't visit my homepage:
 
Sorry for the delay in responses.

Spring does not need an appserver running. It uses jdbc.

As for how I am reading my XML, what do you mean? I am trying to place the currency Spring config files into the JAR so that it recognizes it.

Should it go into the META-INF/classes folder?

I am also looking into using Maven to automatically handle this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top