Will Java compiled in windows work in Linux?

D

D. Xenakis

I have installed on my host linux server online the following file: "traccar-linux-64-2.7.zip (26-Jan-2014)" downloaded from the following link (http://www.traccar.org/download.jsp)

First question: If i want to compile from scratch on my machine using theirsource code unmodificated from here (http://www.traccar.org/source.jsp), would the new generated traccar.run file, have the same hash with "traccar-linux-64-2.7.zip (26-Jan-2014)" ? I mean are they going to be identical?

Second question: Should i compile this through a linux environment? For example Ubuntu, or can i do the compile from Windows environment too? For example windows 8.1 ?
 
M

Marcel Müller

To your subject: yes. (BTDT)
The java byte code is platform independent.
Only JNI code is platform dependent.

But I am not familiar with traccar.


Marcel
 
E

Eric Sosman

I have installed on my host linux server online the following file: "traccar-linux-64-2.7.zip (26-Jan-2014)" downloaded from the following link (http://www.traccar.org/download.jsp)

First question: If i want to compile from scratch on my machine using their source code unmodificated from here (http://www.traccar.org/source.jsp), would the new generated traccar.run file, have the same hash with "traccar-linux-64-2.7.zip (26-Jan-2014)" ? I mean are they going to be identical?

Possibly not. If you compile with a different Java version
than they used, the class file format's version number might be
different. If you use different compiler options than they did,
the class files may contain different kinds and amounts of debugging
information. Even if the class files are identical, the archive's
hash code may be different if you used a different ZIP utility.

The "payload" in the class files should be identical (barring
severe version skew), but you'll need something more context-aware
than a full-file checksum.
Second question: Should i compile this through a linux environment? For example Ubuntu, or can i do the compile from Windows environment too? For example windows 8.1 ?

If the code is entirely in Java, it'll be "the same" (see above)
no matter what environment it's compiled on. If there's any native
(non-Java) code, or if the archive includes things like installers
and such, all bets are off.
 
J

Jukka Lahtinen

Eric Sosman said:
On 3/27/2014 1:50 PM, D. Xenakis wrote:
Possibly not. If you compile with a different Java version
than they used, the class file format's version number might be
different. If you use different compiler options than they did,
the class files may contain different kinds and amounts of debugging
information. Even if the class files are identical, the archive's
hash code may be different if you used a different ZIP utility.

I would say they almost certainly have different hash codes.
The zip file format includes not only the contents of each file packed
in the zip, but also the timestamps of each file, and they WILL be
different when you re-compile the classes, even with an identical
computer with identical operating system, jdk and all possible options.

But because a hash code doesn't contain ALL the information of
the file, there is a slight possibility that they might still happen to
have the same hash code.
 
R

Roedy Green

Java sacrifices quite a bit to be WORA -- run anywhere with the same
Jar unmodified.

If a Java program hard coded in some file names, they might not work
in unix. Ditto presumptions about crlf or default encodings.

If you compile with 1.8, you must run with 1.8 unless you used
-target.

--
Roedy Green Canadian Mind Products http://mindprod.com
"A great lathe operator commands several times the wage of an average lathe
operator, but a great writer of software code is worth 10,000 times the
price of an average software writer."
~ Bill Gates
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top