• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

moving java classes from windows to linux

 
Dave Mere
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

We've recently completed coding a series of java classes designed to download information from a datalogger. These classes connect to the datalogger using sockets, to an IP address on our network. This system was developed on a local machine running a Windows OS. Since transferring it to our linux-based server the classes seem unable to process the output of the datalogger. The systen can still connect to the same IP address but seems to be interpreting the output differently. I have run the classes on a linux-based PC and this produces the same dodgy results.

Has anyone experienced problems in moving java classes between operating systems? Can anyone suggest what might be going wrong?

dave
 
Joe Ess
Bartender
Posts: 9314
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you didn't give us any examples, we're kind of guessing here, but given that you are working with text, I'll bet you are hardcoding end-of-line markers. EOL on windows is "\n\r", "\n" on Unix and "\r" on Macs. Coding for such things is painful, so Java makes it easy. You can obtain the line seperator through the System.getProperty("line.separator") call. You really don't need it since java.io.BufferedReader provides a readLine() method which reads input line by line and both BufferedWriter and PrintWriter have methods to put the platform-specific EOL in output.
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Biggest problem I had in a situation like this was the case of file names (and path names).

In Windows, file names are in both upper and lower case. But when you open the file, the file name is not case sensitive.

In UNIX (or Linux) you can create two seperate files with the same name (but with different case). In Windows, you cannot do this.

So if a logger class uses "mylog.txt" in one spot, and "MyLog.txt" in another spot, it will work differently on UNIX because these names refer to distinct files. In Windows, these names refer to the same file, which could have yet some other case in the actual filesystem name.
 
Dave Mere
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess, you seem to have hit the nail on the head - altering the EOL characters has apparently worked. Many thanks!

Michael Z - thanks for the tip regarding filename case sensitivity. My program will be creating text files so I'll keep that in mind.

Cheers!

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic