LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   A doubt I always had about compilers (https://www.linuxquestions.org/questions/programming-9/a-doubt-i-always-had-about-compilers-410418/)

alek66 02-01-2006 10:40 AM

A doubt I always had about compilers
 
Heres the deal, i´m running a linux under 64bit. I am programming in java... y lets say a make a program, works and everything ok. And i compile it to have a binary. Will this binary work only under 64bit linux only... what´s the deal with the compilators and the outputs rewarding to the arquitecture of your box.
Well actually the thing started to bite my head, when i started thinking in making some programs in java for my palm or cellphone.
Any thoughts, pages, and stuff are welcome.

Hko 02-01-2006 10:59 AM

Because java binaries run on a virtual machine, It's a save guess that it will run on 32-bit Linux as well as Win32, Win64 and Solaris.

BTW AFAIK there does not even exist (yet) a 64-bit java for Linux. So your java-compiler is running in 32-bit mode.

graemef 02-01-2006 10:59 AM

Traditionally a compiler will generate machine instructions specific for the destination architecture, and it is quite possible to build a binary for an architecture different to the one on which the compiler resides (after all it is only generating machine instructions, not trying to execute them)

Traditionally, that was the picture (albeit very simplified) Java and other byte code languages changed that picture a little. The Java compiler will take the source code and generate machine independent instructions which are executed on the target machine via the Java Virtual Machine (JVM) the JVM must reside on the target machine for the java program to work but the source code doesn't need to be recompiled for that specific architecture.

cheers,

graeme

alek66 02-01-2006 12:04 PM

Thanks! for the info.

jlliagre 02-01-2006 02:21 PM

Quote:

Originally Posted by Hko
BTW AFAIK there does not even exist (yet) a 64-bit java for Linux.

There is definitely a 64 bit JVM for Linux available, (for AMD64 Opteron chips).


All times are GMT -5. The time now is 03:07 AM.