This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Runnable jar is not including the files

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
i use Eclipse Ide for my java work and i was working on a program and have some pictures which is in seperate folder and i have a database file when i run it everything is running and one thing more i am not using DSN for my JDBC connection i m using it directly

when i export it to runnable jar it shows me an error and it doent includes the picture folder and the database file
so please help me out i m in a big trouble because i have to show a demo to a college with presentation and my jar is not working so please help me out as soon as possible
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what if you made the top level folder that contains the images be a "source folder" (even though it doesn' thave any code in it)
right click folder, build path, use as source folder .

For some reason anything that is a source folder, the contents get copied into the eclipse built classes folder, i use that to get .xml files in other non-src folders into the jar.

I have never used the eclipse export to jar file thing, it seems too rigid to a mold of what is a typical project, difficult to do special things like jam images in it.

if making the images folder a sources folder doesn't work, are you able to use ant. ?

something like a "package" target in an ant file, that does a compile, (or we can just take advantage of the eclipse building the .java files. and then do a copy image files into the target folder, and then ant the target folder.

in general, its more elegant to rely on ant to do the packaging of a project anyway (than eclipse project export), as it is more accessible to other people who don't use eclipse. but also, sometimes in a pinch its just faster to type something in a console to rebuild things than to boot up eclipse to quickly rebuild the project.

here is an example


eclipse even supports launching ant files from an integrated panel.

see also:

http://ant.apache.org/manual/index.html
 
Marshal
Posts: 74697
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch Vivek Moyal
 
Vivek Moyal
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont get what you said here i get something but not the full

bro i dont know abt ANT that how it work and how i have to work over it

will you give an example of simple jar which include picture in it and its code too so i will see the code and apply it to my code
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, so after you create your class files

#compile, or let eclipse compile for you.
javac -d bin src/*.java

#remove existing jar file, if any
rm -f myjarfile.jar
# or if you'r windows, delete command i guess


then use the jar command that comes with java, such as in a console in the project folder

# grab the class files
jar cf myjarfile.jar -C bin *

# add to the jar file the stuff in the images folder
jar uf myjarfile.jar -C images *
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic