Discussion:
Copy your config files into dist folder
silv
16 years ago
Permalink
Hello,



I have in my project a package 'resources' with all the necessary images, data.xml, property files etc.

I want to distribute my project, so it's easy just to zip the netbeans dist folder (because the libs folder with jdom etc is there) and to extract the zip on an other pc and execute my jar file.

Now my application also uses this resources (e.g the data.xml) to write data to it and because it's packed in a jar, my application crashes...

So I thought to add a folder in de dist folder that contains these resources, but how can I make netbeans doing this? It's easy to edit the resources in the IDE, but with a clean build, Netbeans should copy those new resources in my folder in the dist folder...

Can I do this or do I have to copy them manually? And how do I do it?



Thanks a lot!
Marc Farrow
16 years ago
Permalink
update the build.xml and add a -post-jar target to copy the files. example
below: (tweak for your needs)

<target name="-post-jar">
<copy file="resources/*.*;*" flatten="true" todir="${dist.dir}"/>
</target>
...
Melongo Annabel
16 years ago
Permalink
What build tool are you using, ant or maven?




________________________________
From: silv <***@hotmail.com>
To: ***@netbeans.org
Sent: Monday, April 27, 2009 7:51:28 AM
Subject: [nbusers] Copy your config files into dist folder

Hello,



I have in my project a package 'resources' with all the necessary images, data.xml, property files etc.

I want to distribute my project, so it's easy just to zip the netbeans dist folder (because the libs folder with jdom etc is there) and to extract the zip on an other pc and execute my jar file.

Now my application also uses this resources (e.g the data.xml) to write data to it and because it's packed in a jar, my application crashes...

So I thought to add a folder in de dist folder that contains these resources, but how can I make netbeans doing this? It's easy to edit the resources in the IDE, but with a clean build, Netbeans should copy those new resources in my folder in the dist folder...

Can I do this or do I have to copy them manually? And how do I do it?



Thanks a lot!
raghav
16 years ago
Permalink
please unsubscribe me bcz too many mails




thanks in advance...............
silv
16 years ago
Permalink
Default, so I suppose ant...
Melongo Annabel
16 years ago
Permalink
Now can you please tell me the build scenario once more? I can't really go by what you first posted. I would need a detailed explanation of what you want to do to help you further. Thanks.




________________________________
From: silv <***@hotmail.com>
To: ***@netbeans.org
Sent: Monday, April 27, 2009 1:21:50 PM
Subject: [nbusers] Copy your config files into dist folder

Default, so I suppose ant...
silv
16 years ago
Permalink
Ok, I succeeded copying the files.

But now my hole fileacces system fails :(

How can I easily acces that dir from the jar?

And can I still test in Netbeans? I suppose you can't test as jar and as netbeans project at the same time if you use a certain file acces method?
silv
16 years ago
Permalink
I have a project that reads data from an XML file.

The application edits the readed info and writes it down again to the XML file

The application has to be distributable so all the files are packed in a jar file, but because you can't write to a jar file, I putted the XML file not in the jar but in a dir in the dist folder (I succeeded to do this by the following code:

<target name="-post-jar">

<copy file="${src.dir}/resources/data.xml" flatten="true" todir="${dist.dir}/resources" />

</target>

)

But how can I now easily acces the xml file, because I can't use the classpath from the jar file where the app runs...



Thanks!

Loading...