aspose file tools*
The moose likes Java in General and the fly likes Why Java is called Platform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why Java is called Platform" Watch "Why Java is called Platform" New topic
Author

Why Java is called Platform

sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Hi, I wanna ask a simple question. May be someone laugh finding it very simple, but it will clear my doubts

Why Java is called a platform? I read it that combination of OS and Processor comprises Platform, so why Java is considered as Platform?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39388
    
  28
Welcome to the Ranch

Does this tutorial help answer your question?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

sunny cheng wrote:Why Java is called a platform? I read it that combination of OS and Processor comprises Platform, so why Java is considered as Platform?

You're absolutely right. In fact, the Java language is often referred to as "platform-independent" (meaning that it runs on several OS's).

I think, in Java's case, it usually refers to the JVM, which you can think of as a "language platform", because there are several languages that run on it, not just Java.

Basically, the word 'platform' in this sense means a 'base' or 'foundation'.

HIH

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Thanks Campbell Ritchie

Your tutorial link was helpful. But now I have one more question. If you see in this tutorial they have mentioned that Java platform is (Java API and JVM). Is this the same API that we used in our Program building via import statement(where we include packages) and they are included when we compile it?

If so, then during compiling, we have already brought this classes and packages into our program. Then why are they included as a part of platform as compiled program(which inculdes these classes) can be run on any system having JVM.
sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Thanks Winston Gutkowski

Can you tell what other languages that can be run on JVM??
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

sunny cheng wrote:
Can you tell what other languages that can be run on JVM??


https://en.wikipedia.org/wiki/List_of_JVM_languages


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 174
    
    1

How C can be run in JVM..?

Can we use NetBeans to do it..? How C source can be compiled to run in JVM..?


Ramesh-X
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39388
    
  28
C code is usually compiled directly to some sort of machine code and is not usually compiled to bytecode, so you would have to write your own compiler to run C on the JVM. You can get versions of Eclipse which can compile C code, but I have never used them.
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 174
    
    1

Thank you for the reply..

I think that can be done with netBeans too. (I have never used Eclipse)


What is the best IDE to code java, as you think..?
sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Can any one please help in clearing my doubt on below:

It is mentioned that Java platform/JRE is (Java API and JVM). Is this the same API that we used in our Program building via import statement(like import java.io.* etc) and they are included in our code when we compile it?

If so, then during compiling, we have already brought this API into our program and now we can run our program on any PC. Then why are these API considered as a part of JRE??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
The API classes are not included in your program - they're part of the JRE installation on the machine where you run the program.


Ping & DNS - my free Android networking tools app
sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Thanks for the reply Ulf. But can you please elaborate it.

What I have heard then when you make a Java program including some libraries classes and package(API), they are included in your program when we compile it. For e.g.

import java.util.*;

class A{
}


So are these same API that are part of JRE?
Also I didn't get this line "they're part of the JRE installation on the machine where you run the program. "
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
You have heard incorrectly. As I said, the Java (i.e., JRE) API classes are not included in your program. Only your classes (and maybe other libraries that you choose to include) become part of the program.

That line means that the classes get installed on a machine when you install the JRE. If a machine has no JRE installed, you can't run Java programs.
sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Thanks Ulf, Appreciate your reply.

so based on you reply Can I conclude by saying this :

API classes in JRE and API(like java.io.*,java.util.*) that we include in our program are two different sets of API? As till now I was having this in my mind that both are same thing.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
No. There is only one API, and one set of classes that implements it. You are not including anything in your program by merely using it.
sunny cheng
Greenhorn

Joined: Mar 27, 2013
Posts: 7
Ulf, can you please explain you reply with an example??

What I understood from this is : There is only one set of Java API(all the classes and packages which we used in our programs as well), and that is a part of JRE.

java.io,java.util,java.lang......all ---------------------belong to ----------------------> Java API



we are importing these classes means "import only tells the compiler where to look for symbols."
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
Not sure what to explain - you seem to have grasped the concept now.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

sunny cheng wrote:
we are importing these classes means "import only tells the compiler where to look for symbols."


I wouldn't even put it that way. Importing is just syntactic sugar. If you import nothing or one class or two classes or 100 classes, the bytecode in the .class file will be identical. Importing has no effect at all on the .class file produced by the compiler. The only thing it does is save us some typing and allow our code to be a bit less cluttered. It lets us write List instead of java.util.List, and so on. That's all it does, nothing more.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why Java is called Platform