File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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?

dave
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[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.

Cheers!

Dave
 
GeeCON Prague 2014
 
subject: moving java classes from windows to linux