Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > how to use resources in jar

Reply
Thread Tools

how to use resources in jar

 
 
daniele daniele is offline
Junior Member
Join Date: Oct 2007
Posts: 1
 
      10-17-2007
hi,
i have a jar file with 2 reosources, when i use the reosources in jar file it's all ok.
If i import the file jar as library and use it in a new file Prova i recive the following message:

ERRORE: '/home/gianni/workspace/Prova/file:/home/gianni/JfuzzyLogicFML.jar!/net/sourceforge/jFuzzyLogic/fml2fcl.xsl (No such file or directory)'.

i have duplicate path and i don't get resources right....

how can do to work right?

public class Resources {

this is the class that manage resources;

public enum ResourceName{
fmlSchema,
xslt,
}

/**
* @uml.property name="properties"
*/
private static final String resourceName[] = new String[]{
"fmlSchema.xsd",
"fml2fcl.xsl"
};

/**
* @uml.property name="singleton"
*/
private static Resources singleton;

/**
* @throws Exception
*/
public static Resources getInstance() throws Exception {
if (singleton == null) {
synchronized (Resources.class) {
if (singleton == null) {
singleton = new Resources();
}
}
}
return singleton;
}

/**
* Constructor
*
* @throws Exception
*/
private Resources(){
mapResources = new HashMap<ResourceName, File>();
}

Map<ResourceName, File> mapResources;

public File getResource(ResourceName name){
File file;

file = mapResources.get(name);
if( file == null ){
file = new File( getClass().getResource(resourceName[name.ordinal()]).getPath());
mapResources.put(name, file);
}

return file;
}

}


and here i s where i use it:
public static FIS loadFML(String fmlFilePath, boolean verbose) throws SAXException {
FMLValidator validator = new FMLValidator();

File xml = new File(fmlFilePath);

File fmlSchema = resources.getResource(Resources.ResourceName.fmlSc hema);


File xslt = resources.getResource(Resources.ResourceName.xslt) ;

validator.validate( xml , fmlSchema.getPath());

String fclDefinition = FML2FCLTransformation.transform( xml , xslt);
System.out.print(xslt);
return createFromString(fclDefinition, verbose);

}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM



Advertisments