Will Jar files/classes work if moved from Linux to Windows?

O

ohaya

Hi,

I have a Java program that I'm working on, using J2SDK 1.4.2. Right
now, it's being developed on a Linux machines, and uses a bunch of
classes that are contained in some vendor-provided Jar files.

I have J2SDK 1.4.2 installed on a Win2K machine.

If I just move the Jar files from the Linux machine to my Win2K machine,
and re-compile my program on the Win2K machine, will the program be able
to run on the Win2K machine?

Thanks,
Jim
 
N

Niels Dybdahl

I have a Java program that I'm working on, using J2SDK 1.4.2. Right
now, it's being developed on a Linux machines, and uses a bunch of
classes that are contained in some vendor-provided Jar files.

I have J2SDK 1.4.2 installed on a Win2K machine.

If I just move the Jar files from the Linux machine to my Win2K machine,
and re-compile my program on the Win2K machine, will the program be able
to run on the Win2K machine?

Probably yes. You do not even have to recompile your own application.

Niels Dybdahl
 
S

Sam Jervis

ohaya said:
Hi,

I have a Java program that I'm working on, using J2SDK 1.4.2. Right
now, it's being developed on a Linux machines, and uses a bunch of
classes that are contained in some vendor-provided Jar files.

I have J2SDK 1.4.2 installed on a Win2K machine.

If I just move the Jar files from the Linux machine to my Win2K machine,
and re-compile my program on the Win2K machine, will the program be able
to run on the Win2K machine?

Thanks,
Jim

Yes, and in fact you shouldn't even need to recompile your class files.
Java class files are platform independent i.e. you can copy them onto
any machine that has a JVM and run them unaltered. This is regardless
of the endianness of the platform too. A Jar file is just a zip file
containing Java class files (and supporting resources) and so again can
be copied to any platform unaltered.

I'm assuming of course that your program is pure Java and isn't relying
on anything Linux specific, but this seems like a fair assumption to me.

Sam
 
S

Steve Horsley

ohaya said:
Hi,

I have a Java program that I'm working on, using J2SDK 1.4.2. Right
now, it's being developed on a Linux machines, and uses a bunch of
classes that are contained in some vendor-provided Jar files.

I have J2SDK 1.4.2 installed on a Win2K machine.

If I just move the Jar files from the Linux machine to my Win2K machine,
and re-compile my program on the Win2K machine, will the program be able
to run on the Win2K machine?

Thanks,
Jim

As you've already heard, you should be able to just copy the jar files
and run them.

The catches are things like:
* Your code expects '/' rather than '\\' in file paths
* your code outputs '\n' rather than '/r/n' between lines
* you rcode assumes files are in ASCII but you are on a machine
where text is stored in EBCDIC (like an AS/400).

These are all problems where you make assumptions about the machine
you're on. Java has system properties that will tell you these things
(System.getProperty("line.separator")) for instance. As long as you
avoid system specific assumptions, you will be OK.

Steve
 
O

ohaya

Steve said:
As you've already heard, you should be able to just copy the jar files
and run them.

The catches are things like:
* Your code expects '/' rather than '\\' in file paths
* your code outputs '\n' rather than '/r/n' between lines
* you rcode assumes files are in ASCII but you are on a machine
where text is stored in EBCDIC (like an AS/400).

These are all problems where you make assumptions about the machine
you're on. Java has system properties that will tell you these things
(System.getProperty("line.separator")) for instance. As long as you
avoid system specific assumptions, you will be OK.

Steve


Hi Steve et al,

I'm happy to report that the 'transplant operation' was SEMI-successful
:).

I moved the jars and my .java file over, and recompiled (just to make
sure that I knew the classpath was working ok). The compile went fine,
but my first execution gave me an error. It appears that the code,
which uses JSS/NSS, does some native calls.

I was a bit disappointed at first, but then I was kind of curious why it
was calling what it was calling. It turned out it was doing some stuff
which it didn't really need to do (the program was a modification of
some code from a Netscape package), so I decided to try to delete that
extraneous stuff, hoping that that was the only place the native code
was being called.

I was pleasantly surprised when I got both a clean compile and an
execution without any exceptions!!!

So, it looks good.

Thanks for all of your help...

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top