I have an application that works perfectly in the eclipse launcher but not in the executable jar, I have copied the src into the jar and the .properties but I get this error:
Error in ConfigXML.java: problems with src/main/resources/config.xml
java.io.FileNotFoundException: C:\Users\victo\Desktop\IS1\config.xml (The system can not find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at configuration.ConfigXML.<init>(ConfigXML.java:84)
at configuration.ConfigXML.<clinit>(ConfigXML.java:76)
at gui.ApplicationLauncher.main(ApplicationLauncher.java:20)
null
Exception in thread "main" java.lang.NullPointerException
at java.util.Locale.<init>(Unknown Source)
at java.util.Locale.<init>(Unknown Source)
at gui.ApplicationLauncher.main(ApplicationLauncher.java:24)
These are that lines of the ApplicationLauncher.java:
public class ApplicationLauncher
{
public static void main(String[] args)
{
ConfigXML c=ConfigXML.getInstance();
System.out.println(c.getLocale());
Locale.setDefault(new Locale(c.getLocale()));
System.out.println("Locale: "+Locale.getDefault());
And the ConfigXML:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<businessLogic local="true">
<businessLogicNode>0.0.0.0</businessLogicNode>
<businessLogicPort>1099</businessLogicPort>
<businessLogicName>Bets</businessLogicName>
</businessLogic>
<database local="true">
<databaseNode>0.0.0.0</databaseNode>
<dbFilename>src/main/resources/bets.temp</dbFilename>
<dataBaseOpenMode>open</dataBaseOpenMode>
<databasePort>6136</databasePort>
<user>admin</user>
<password>admin</password>
</database>
<locale>en</locale>
</config>
The config.xml is in the resources folder of the jar so I don't know what this happens, thanks.
The solution is to paste the src folder next to the jar file, I have pasted it inside the jar file too using WinRar. It is because there is a line in the config xml that points to src/resources as the path of the needed resources