Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

exeunt (319)

  reversethis-{} {ta} {izaguf}

My perlmonks Personal Node []

Journal of exeunt (319)

Wednesday May 15, 2002
03:21 PM


[ #4945 ]

As part of my job, I have to deal with some Java. Which isn't too bad, since I don't have to write it, I just have to make sure things compile, pass tests, etc.

We are getting ready to open source the framework our RnD team has been working on for the past year. There sure seems to be a lot of Java Frameworks out there. This one is specialized to the Aerospace Industry, so don't get too excited. I'll post more later, if someone is really dying to know more about it, and after we push the stuff out to sourceforge.

Back to the story at hand, which is portability. One of the main developers asks me to try running the JUnit tests on a unix server, since they do all their coding/testing/etc on windows machines. So I check out the latest version off our internal cvs server on the rnd linux server, and run junit tests. I get this nasty error from one of the unit tests about not being able to find a directory in the CLASSPATH to write a temp test file too.

My first impressions was that it was a permissions issue, so I chown a test directory to 777, and re-run it, same error. After I rechown the directory back to it's previous mode, I try running this off my windows machine. No error. Puzzled, I check the source code.

Here is a small section of the code:

    String cp = System.getProperty("java.class.path");
    StringTokenizer stknzr = new StringTokenizer(cp, ";");
    while (stknzr.hasMoreTokens()) { ...

I quickly insert a System.out.println("Classpath: " + cp); and get a copy of the classpath. I notice something funny, the classpath separator is a :, not a ; as stated in the code. I run the same code, to output the classpath on windows, and the separator is ;. As a test, I change the ; to a : real quick, re-run it, and it works on unix now (imagine that!).

Now to make it portable. Since only how to do simple hello world and other stupid tricks in java, I was thinking I'd have to go down an ugly path of knowing what system I am on, and setting some variable to pathSeperator, or leave it up the real java programmers. Just as a quick step, I check google, and find my answer: System.getProperty("path.separator"). Now instead of the ";" it has the path.sperator value in there.

All is good now. Now to beat my developers into a portability mindset in the first place, and to find where else it won't work (find . -type f -name "*.java" | xargs grep '";"' turned up a few places they will have to re-visit).

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.