Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2008

Tip: Looking for answers? Try searching our database.

JAR-How to add files

Thread view: 
Chase Preuninger - 20 Apr 2008 04:41 GMT
I am running netbeans and I have a rtf I want to put in the jar that
is built with my app so that I can read off it later when my program
is running.  The only problem is that I don't know how to get it into
the jar.
Roedy Green - 20 Apr 2008 04:49 GMT
On Sat, 19 Apr 2008 20:41:24 -0700 (PDT), Chase Preuninger
<chasepreuninger@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>I am running netbeans and I have a rtf I want to put in the jar that
>is built with my app so that I can read off it later when my program
>is running.  The only problem is that I don't know how to get it into
>the jar.

you could put it in like any other resource.

see http://mindprod.com/jgloss/jarexe.html
or use an ANT script.
see http://mindprod.com/jgloss/ant.html
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Chase Preuninger - 20 Apr 2008 05:05 GMT
that would work but I am talking about in the context of netbeans
Mark Space - 20 Apr 2008 05:18 GMT
> that would work but I am talking about in the context of netbeans

Right click on the package you want it in, select "Empty File" (you
might have to go down to "Other" and use the wizard).  Type in the file
name.

Then just replace that blank file with yours.

I think you can just drop files in the source dir and they'll be
included in the .jar, but I'm not sure about that.  I'm 99% sure the
directions in the first paragraph will work.  Play around with it.
Chase Preuninger - 20 Apr 2008 12:09 GMT
the second one does work!
Chase Preuninger - 20 Apr 2008 05:13 GMT
also if I wanted to read the file out of the same jar that contains my
running app, what is the beast way to do so?
Mark Space - 20 Apr 2008 06:08 GMT
> also if I wanted to read the file out of the same jar that contains my
> running app, what is the beast way to do so?

<http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#getResourceAsSt
ream(java.lang.String
)>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.