File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Java is called Platform

 
sunny cheng
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47300
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Does this tutorial help answer your question?
 
Winston Gutkowski
Bartender
Pie
Posts: 9497
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sunny cheng
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Winston Gutkowski

Can you tell what other languages that can be run on JVM??
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sunny cheng wrote:
Can you tell what other languages that can be run on JVM??


https://en.wikipedia.org/wiki/List_of_JVM_languages
 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How C can be run in JVM..?

Can we use NetBeans to do it..? How C source can be compiled to run in JVM..?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 178
2
Java MySQL Database Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API classes are not included in your program - they're part of the JRE installation on the machine where you run the program.
 
sunny cheng
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what to explain - you seem to have grasped the concept now.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic