File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes moving java classes from windows to linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "moving java classes from windows to linux" Watch "moving java classes from windows to linux" New topic

moving java classes from windows to linux

Dave Mere
Ranch Hand

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

Joe Ess

Joined: Oct 29, 2001
Posts: 9189

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 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.

[How To Ask Questions On JavaRanch]
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
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

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


I agree. Here's the link:
subject: moving java classes from windows to linux
It's not a secret anymore!