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?
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.
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.
Joined: Oct 25, 2004
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.