Results 1 to 17 of 17
- 05-01-2014, 11:55 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Behaviour of the program with Netbeans and without Netbeans different?
Hello community,
i have a really strange behaviour of my program.
I have a program written, that loads data from an csv file into my program.
This is possible with the library named jCSV (https://code.google.com/p/jcsv/)
When i start my program with F5 or the PlayButton in Netbeans, my program starts.
I load the csv data into my program and can go further on.
I check the data in the program and see, that the data was loaded successfully and also special signs are written correctly.
For example "Pauls`s Academy" (All special signs are written correctly. UTF-8 conform)
When I check now the folder dist, there is my program called server.jar with a extra folder lib.
I start now the program right out the windows explorer. (Without Netbeans)
The program starts, I load the same csv like before, but after loading I have the strange behaviour that the data is not UTF-8 conform?!?
When I now have a look at my data I see the same senctence: "Paul<?>s Academy"
How can that happen, that the program without Netbeans have another behaviour as with Netbeans?
So and the next question is, how can i solve this? I don`t know where i should have a look or what I should do.
Hopefully somebody can help me out of here
Thanks
- 05-02-2014, 10:33 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Behaviour of the program with Netbeans and without Netbeans different?
What are you using to check the loaded data?
Is it displayed in a Swing text area, or on the console?Please do not ask for code as refusal often offends.
** This space for rent **
- 05-02-2014, 11:42 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
It is shown up in a Swing text area
- 05-02-2014, 02:23 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Behaviour of the program with Netbeans and without Netbeans different?
Oh...well there goes my one idea.
The text area should handle UTF-8, as that's what it works with.
I know this is the same file being loaded, but is the file UTf-8 or some other character set?Please do not ask for code as refusal often offends.
** This space for rent **
- 05-05-2014, 10:56 AM #5
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
The file is exported with character st utf-8
No other program has opened changed the files.
After that error, when i start netbeans and the program, load the same files again, it is working again X)
- 05-06-2014, 11:52 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Behaviour of the program with Netbeans and without Netbeans different?
I'm afraid I'm at a loss.
It's one of those problems that needs you to step through the code and see whether it is during reading in, or writing out, that the problem occurs.Please do not ask for code as refusal often offends.
** This space for rent **
- 05-08-2014, 10:15 AM #7
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
It's one of those problems that needs you to step through the code and see whether it is during reading in, or writing out, that the problem occurs.
Because with Netbeans the code and the program are working perfectly.
When i take only the .jar File and start this one (without Netbeans) than it isn`t working. So no chance to debug
Maybe there is anybody else here that has a solution?
- 07-01-2014, 05:31 PM #8
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
Can I push this thread pls (Problem still occures)
- 07-01-2014, 05:44 PM #9
Re: Behaviour of the program with Netbeans and without Netbeans different?
Try debugging the code by adding lots of println() statements that print out the values of variables as they are changed and used.
Open a command prompt window, change to the folder with the jar file and use the java -jar THEJARFILENAME.jar
command. The print out will go on the console window. The output should help you understand what the program is doing.If you don't understand my response, don't ignore it, ask a question.
- 07-01-2014, 05:55 PM #10
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: Behaviour of the program with Netbeans and without Netbeans different?
That is one thing, I also wonder how Netbeans starts the Java application. Which flags are passed to the runtime? Its been a long time since I used Netbeans, but I think somewhere in the project view you can see the exact Java command that will be invoked by Netbeans. But perhaps I now go so far back in time that it was a version of Netbeans that is not designed around ANT.
I am making a wild guess, but I have a suspicion that Netbeans is overriding the platform default encoding with UTF-8 when running the application."Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 07-01-2014, 07:22 PM #11
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
So more infos:
I thought the problem could be in the library i have used (jscv), so i switched to opencsv.
The same behaviour X/
Try debugging the code by adding lots of println() statements that print out the values of variables as they are changed and used.
Open a command prompt window, change to the folder with the jar file and use the java -jar THEJARFILENAME.jar
command. The print out will go on the console window. The output should help you understand what the program is doing.
There must be a problem with Netbeans!
Java Code:List<String[]> taenzer; reader = new FileReader(file.getAbsolutePath()); CSVReader csvTanz2TaenerReader = new CSVReader(reader); taenzer = csvTaenzerReader.readAll(); for(String[] temp : taenzer) { System.out.println(temp[0]+temp[1]+temp[2]+temp[3]+temp[4]); }
012MaxMüstermann
without IDE:
012MaxMÄ1/4sstermann
The library is in the classpath!
I am making a wild guess, but I have a suspicion that Netbeans is overriding the platform default encoding with UTF-8 when running the application.
Or where can i define this code?
- 07-02-2014, 10:05 AM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Behaviour of the program with Netbeans and without Netbeans different?
Well, that Sysout will print to the console, which will not handle UTF8 anyway.
It's not much of a test.
Also, if you're writing to a txt file and then opening in something like NotePad you'll get the same problem.Please do not ask for code as refusal often offends.
** This space for rent **
- 07-02-2014, 12:09 PM #13
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
Normaly I would write the data into a database (hsqldb) instead of "System.out..."
Java Code:for(String[] temp : taenzer) { //System.out.println(temp[0]+temp[1]+temp[2]+temp[3]+temp[4]); tid = Integer.valueOf(temp[0]); //Check if it is really an integer sid = Integer.valueOf(temp[1]); nachname = temp[2]; vorname = temp[3]; geburtsdatum = temp[4]; try { sqlFunctions.setExecuteUpdate("INSERT INTO TAENZER " .concat("(taenzerid, SID, VORNAME, NACHNAME, GEBURTSDATUM) VALUES (") .concat(String.valueOf(tid)).concat(",") .concat(String.valueOf(sid)).concat(",'") .concat(vorname).concat("','") .concat(nachname).concat("','") .concat(geburtsdatum).concat("')")); } catch (SQLException ex) { throw new StandardException("Error 8725"); } counter++; }
What am I doing wrong?
- 07-02-2014, 12:43 PM #14
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: Behaviour of the program with Netbeans and without Netbeans different?
Who knows what you're doing wrong. It would benefit you greatly to take this as a hint and research character encoding in general and then how that is applied within the context of Java to gain a better understanding and be able to recognize yourself what you may be doing wrong.
Until then, all you can do is just try stuff and hope for the best. So try this. Instead of this:
Java Code:reader = new FileReader(file.getAbsolutePath());
Java Code:reader = new InputStreamReader(new FileInputStream(file), "UTF-8");
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 07-02-2014, 01:11 PM #15
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Re: Behaviour of the program with Netbeans and without Netbeans different?
Thank you all for your help and thank you twice gimbal2 for the Code!!
With FileInputStream and UTF-8 it is working!!
Wish you all a nice day
- 07-02-2014, 01:29 PM #16
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: Behaviour of the program with Netbeans and without Netbeans different?
Crap, you got a code answer and didn't learn anything. This thread is now a failure and its my fault.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 07-02-2014, 02:02 PM #17
Member
- Join Date
- Oct 2012
- Posts
- 45
- Rep Power
- 0
Similar Threads
-
Old Java Program in NetBeans
By Silvia Todorof in forum NetBeansReplies: 3Last Post: 12-19-2011, 05:08 AM -
Written Java Program in Netbeans won't compile..
By ptrasd12 in forum New To JavaReplies: 5Last Post: 12-01-2011, 02:43 PM -
how to run my java program made in netbeans to another PC?
By kwink in forum AWT / SwingReplies: 2Last Post: 03-22-2009, 07:43 PM -
netbeans+swing = painting program?
By yuriythebest in forum New To JavaReplies: 3Last Post: 12-14-2008, 09:55 PM -
Program Runs in NetBEans but Not in cmd
By MeathUltra in forum NetBeansReplies: 1Last Post: 12-09-2008, 06:38 AM
Bookmarks