Question:
Java: Compatability with all computers?
Adam
2012-11-16 20:22:18 UTC
Hi guys,

So I've been studying on Java for a few days now. I'm a complete amateur. The only other work I've ever done with programming is Lua, which is probably considered a low to mid level program language, but the knowledge has helped me alot despite the languages being completely different.

I didn't have to relearn the concent of conditional statements, subroutines (called functions in Lua) loops, etc.

There is just one thing that I want to get a little bit of extra understanding of: Java compatability with other computers.

I have several questions:

1.) How do java apps, like online Java video games for example, work on anybodies computer? Is there some sort of compiler built in, or is it an interpretor? (Some specific examples are RuneScape, Minecraft, etc)

2.) The guide I am reading says that this is because every type of computer has it's own machine language, and Java has to be compiled differently for each. Where do computer machine languages vary? Is it dependant on it's operating system, brand, or each individual computer?

Thank you for your time in reading this thread. I hope somebody can help me. If you can only answer one of my questions, this is perfectly fine.
Three answers:
Kaydell
2012-11-16 20:40:17 UTC
Java comes with two main parts. 1) The Java compiler which takes source-code written in Java and generates byte code that is compatible with the Java Virtual Machine (JVM). 2) The JVM which takes byte code as its input and actually runs the software.



Software built using Java can run on Windows or Mac because the byte code is the same. Byte code isn't the same as machine code. Byte code are instructions in the JVM whereas machine code are instructions for a particular processor.



Machine languages vary according to the processor. Also, different platforms such as Windows and Mac have different operating system calls available which impact software.



Another term to know is "cross-platform". Java is cross-platform meaning that it will run on more than one platform.



Well, I suppose people could write books on what makes Java cross-platform.



"Head First Java"

http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208/ref=sr_1_5?ie=UTF8&qid=1353127178&sr=8-5&keywords=beginning+Java
Guru
2012-11-16 20:43:47 UTC
Please read about Bytecode and JVM these 2 are resposible for platform independent feature of Java. Well when compile Java program your source code converted into Bytecode an intermediate language which not undersatndable by your OS. So JVM comes into action.

In traditional compilation process source code get compiled in Native Code (depends on OS).

Here is difference -Bytecode and Native code.

And JVM is present with all major (all most all) OS, so your Java program runs on any OS.



Simple.

Regards
Maurizio
2012-11-16 20:27:42 UTC
Basically sometimes on any pc you have the anoying java updates. Every computer is comatible with it and thus this add on runs the programs. Much like flash player runs (or used to ) run youtube clips. Also say on the mac the java apps are not native mac apps rather they are java apps.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...