• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java platform independent?

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why java is called platform independent language?
because c++ can also be run in different platforms?

can anyone explain?
[ November 13, 2007: Message edited by: Bear Bibeault ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java not just the source but also the compiled bytecode is the same across all platforms. You can take compiled Java code and run it on any JVM on any system.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now i'm annoyed. as i typed my answer in your other thread, Marc answered it in this thread. so, either he or I have now wasted our time givng the same answer to the same question.

I have deleted your other copy of the thread.
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what happens in C/C++ then?


cant we do the same thing there?
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no, you cannot. when you compile your C/C++ code, you change it into machine language. that language is native to a specific CPU.

Think of it this way... each kind of computer speaks it's own language. French, German, Italian, Farsi, Chinese... whatever.

the C/C++ way:
Think of my source code as English. I write the document in English (as I am a native English speaker). If i want to sent that document to each country, I have to translate it into each of those languages. I have to send the French one to France, the Chinese one to China, etc.

The Java way:
Now with java, it's a little different. the find folks at SUN computing have sent an interpreter to each country. I can now write my document in English, and send the EXACT same document to everywhere in the world. the interpreter in each country picks up the document, and they translate it into the local language.
[ November 13, 2007: Message edited by: Fred Rosenberger ]
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sir,

when people say its platform independent are they reffering to the hardware architecture or the operating system?
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that is going to depend on the person speaking. it could mean either.
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how does the interpretor work? Does it take token by token or line by line from the bytecode?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you run your Java program, the JVM executes the compiled bytecode. It does not use the source code of your program. There are no tokens and lines in the bytecode. Bytecode looks like machine code instructions.
[ November 14, 2007: Message edited by: Jesper Young ]
 
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic