Results 1 to 4 of 4
- 08-31-2009, 05:48 PM #1
Member
- Join Date
- Aug 2009
- Location
- Bruxelles, Belgium
- Posts
- 2
- Rep Power
- 0
Stream problem when I export my project in a .jar executable archive
Hello everyone,
My problem is that I have made a program that use Output and Input Streams for saving data in a file. While I try it in my IDE (NetBeans 6.7.1) everything works perfectly well. But when I try to use my .jar executable, my program works well but can't read nor write data’s!
Have somebody an idea why it doesn't work ?
Thanks for your answers
P.S. I beg your indulgence for my English. I speak French and have never had any English course …the most English I learned is from javaDoc ;-)Last edited by Arsenicmic; 08-31-2009 at 05:50 PM.
-
Mr. Poison:
Your English is fine, so please don't worry about that.
I am no expert in Applets but I do know that to read and write files from a host machine requires proper permissions (a "signed" applet). Question: must this application be an applet? Also, what do your I and O routines look like? Are you looking for the files in the correct locations? And what error messages do you get?
Best of luck!
- 08-31-2009, 06:25 PM #3
Writting: You cannot easily write data to a jar file (though it can be done). If you write to a file it is easier to save it onto the host machine. If you want to know where that is:
Java Code:File file = new File(""); System.out.println(file.getAbsolutePath());
Reading:
You can open a data file in a jar but you must give the path of that data file otherwise it doesn't know where to look.
You can derive the path by using an object's class information:
Java Code:System.out.println(this.getClass().getResource("")); //see jar path for this classJava Code:File file = null; try { file = new File(this.getClass().getResource("resources/myFile.txt").toString()); //adjust the directory and file name can use ".." to back a directory if need be } catch(Exception e) { System.out.println("This File doesn't exist!"); }My Hobby Project: LegacyClone
- 09-07-2009, 08:27 AM #4
Member
- Join Date
- Aug 2009
- Location
- Bruxelles, Belgium
- Posts
- 2
- Rep Power
- 0
Thank you two
Thanks, really!
I didn't expect to get so quick answers. And I want to apologize for answering still now, because in fact, I did realize one or two day after that my problem was my own stupidity! The directory in witch I export my projects have been renamed (certainly a mistake of mine) so that I have been trying the same old version (in witch there was a problem of IO streams that I solved)!!!! And in the meantime, my corrected version was waiting me in a secret place of my computer!
So I am truly sorry for wasting your time, and happily surprised of how quick you can get answers here. (It was my first post on a forum... for a first one, that's not a true success!)
So thank you very much
Arsenic Mic
Similar Threads
-
Problem Jar executable files
By Manfizy in forum New To JavaReplies: 6Last Post: 08-13-2009, 01:15 PM -
Executable java project ..
By xVent in forum Java AppletsReplies: 5Last Post: 03-29-2009, 06:46 PM -
Problem in Export to Excel using Jexcel api
By Padmalatha in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 11-19-2008, 08:09 AM -
Zip Archive Problem
By satishbejgum in forum Advanced JavaReplies: 1Last Post: 12-20-2007, 09:08 AM -
problem with the way to export data to CSV file
By gonne in forum Java ServletReplies: 0Last Post: 07-01-2007, 02:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks