Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Problem with ClassLoader not picking up external config file
 Post subject: Problem with ClassLoader not picking up external config file Post rating: 0   New post Posted: Sat 09 Aug, 2014, 13:22 
User avatar

User rating: 11
Joined: Tue 27 Mar, 2012, 17:47
Posts: 111
Location: GermanyGermany
Hello Support,

I'm trying to read an external config file for my strategy.
This config file must not be included in the external jar, since I do not want to recompile on every property change in this file.
In the attachment I have created a simple strategy which uses an external jar(you need to adapt the path to the jar of course).

In the jar example you can see that the xml file is correct loaded when it is in the jar file.
But I cannot get it loaded if the xml file is external to the jar(I tried the simplest case and putted the xml file into the same folder as the jar file).
You can also see that the MANIFEST.MF has one entry for the Class-Path: .
This means the current directory and I don't know why the Dukascopy classloader(com.dukascopy.dds2.greed.agent.a.c) does not look up this folder.

Please help, since I think that config files are very useful.

Thanks,
Juergen


Attachments:
ClassLoaderTest.zip [4.05 KiB]
Downloaded 84 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Problem with ClassLoader not picking up external config file Post rating: 0   New post Posted: Wed 13 Aug, 2014, 09:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Why are you trying to load a resource by classloader which is not within its classpath? Why not simply use the FileInputStream?


 
 Post subject: Re: Problem with ClassLoader not picking up external config file Post rating: 0   New post Posted: Wed 13 Aug, 2014, 10:23 
User avatar

User rating: 11
Joined: Tue 27 Mar, 2012, 17:47
Posts: 111
Location: GermanyGermany
For FileInputStream you need the absoulte path to work.
I want to be able to put the xml file relative to the jar.
And since this may differ on any machine I want to be independent of absolute paths.

I have no problems with normal applications to put config files relative to jars, but only when using JForex.
This is because the path starting with "jfx://..." does not give me a local file path which may be because it is a JavaFX application?!

Can you provide a solution with a relative path working?


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com