1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why JAVA is platform independent?

Discussion in 'Other Languages' started by seoways, Jul 19, 2013.

  1. seoways

    seoways Jr. VIP Jr. VIP Premium Member UnGagged Attendee

    Joined:
    Dec 19, 2009
    Messages:
    4,658
    Likes Received:
    724
    Location:
    Behind you!
    Java is said to be platform independent. Because, all the java codes will be running on JVM (Java Virtual Machine) where as c and c++ are depends on the operating system. First the JIT (Just in Time) compiler convert the program into byte code (that is .class file) once you compile it on JVM.
    The byte code has the capability to run on any operating system if OS has JVM.
    So, Java is definitely Platform Independent Language.
     
  2. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,290
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
    because for example C#/VB and etc.. require certain libraries and dependancies to be installed on your OS upfront. While Java requires no outside dependancies and libs except the ones in the JVM
     
  3. Xp3r7

    Xp3r7 Regular Member

    Joined:
    Sep 9, 2011
    Messages:
    286
    Likes Received:
    386
    Occupation:
    Freelancer
    Location:
    In the middle of nowhere
    So you're answering your own question?
     
    • Thanks Thanks x 2
  4. phracktl

    phracktl Regular Member

    Joined:
    Sep 2, 2012
    Messages:
    218
    Likes Received:
    152
    You didnt answer why at all.

    Simply:

    To fulfil a dream of "write once, run anywhere"
     
    • Thanks Thanks x 1
  5. seoways

    seoways Jr. VIP Jr. VIP Premium Member UnGagged Attendee

    Joined:
    Dec 19, 2009
    Messages:
    4,658
    Likes Received:
    724
    Location:
    Behind you!
    Java mainly concentrates on security and compatibility purpose. In Java there is no need to fetch the physical memory so, it is more secure than other languages. Though there are many language, java is considered as a secure language. Moreover Android is based on java program.
     
    Last edited: Jul 20, 2013
  6. UnSourCeR

    UnSourCeR Regular Member

    Joined:
    Aug 19, 2011
    Messages:
    208
    Likes Received:
    47
    The "platform" here means computer type - mac, pc, nokia mobile phone (yes, this is a computer too); and also operating system - windows, linux, and so on.
    if you write an "application" or a script in java, any of these systems can run it and it will more or less look and work exactly the same.
    this is because java program is actually not run directly by the computer as a for example .exe application, but "interpreted" by so called JVM (java virtual machine) - a robot application which was already installed in the computer beforehand.
    thus it is not "dependent" on what computer you have.
     
  7. Junkfood00

    Junkfood00 Elite Member

    Joined:
    Sep 13, 2011
    Messages:
    1,949
    Likes Received:
    1,336
    So what's the point here?
     
  8. seoways

    seoways Jr. VIP Jr. VIP Premium Member UnGagged Attendee

    Joined:
    Dec 19, 2009
    Messages:
    4,658
    Likes Received:
    724
    Location:
    Behind you!
    So, if you really need to do secure and compatible program just switch to JAVA!!!
    Just know the use of .class file (hexadecimal) which can in run any platform.
     
  9. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,364
    Likes Received:
    5,425
    Gender:
    Male
    Location:
    South Africa
    Home Page:
  10. Junkfood00

    Junkfood00 Elite Member

    Joined:
    Sep 13, 2011
    Messages:
    1,949
    Likes Received:
    1,336
    I already use Java, thanks for the tip though. :)
     
  11. DarkPixel

    DarkPixel Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 4, 2011
    Messages:
    1,328
    Likes Received:
    1,239
    Location:
    ↓↓↓↓
    Home Page:
    Java isn't so "secure". Decompiling it is pretty easy.
     
  12. rutix

    rutix Junior Member

    Joined:
    Sep 6, 2012
    Messages:
    102
    Likes Received:
    12
    well c and c++ are not dependable on the OS if you write portable code. Of course you will need to compile it, but they are way faster than java.
     
  13. phracktl

    phracktl Regular Member

    Joined:
    Sep 2, 2012
    Messages:
    218
    Likes Received:
    152

    Thanks for the heads up :)

    I must have somehow missed the point of Java through my ComSci MSc and my 10 years as a {C|C++|Java/...} developer and consultant
     
  14. killersoft

    killersoft Newbie

    Joined:
    Jul 8, 2013
    Messages:
    12
    Likes Received:
    5
    Occupation:
    software developer
    Location:
    Poland
    Java is not compatible "as is", code have to be also compatible. If you wrote your code, to use some Windows typical features, like desktop directory etc. it will not be portable.

    There is very large number of things that you can make and these things will not be portable - like GUI application - can run on windows and unix, but not on Android.

    Compatibility means that you don't have to re-compile your code for every platform and, you don't have think about some hardware or OS-spec things like "is this number 32 or 64bits long? in which order are bytes of integer send by network?" etc. etc.

    Also using Java dosen't guarantee you security - you must write code in secure way, think about potentialy dangerous usages/hacks of your software.
     
  15. s0ap

    s0ap Executive VIP Jr. VIP Premium Member

    Joined:
    Sep 23, 2008
    Messages:
    230
    Likes Received:
    810
    Occupation:
    :] guess
    Location:
    Congo/DRC
    I'm not sure what planet you are from but it definitely isn't Earth.
     
    • Thanks Thanks x 1
  16. KevinK

    KevinK Junior Member

    Joined:
    Jul 24, 2008
    Messages:
    159
    Likes Received:
    87
    I learn so much here from noobs.... NOT!!

    Java is compiled into bytecode. A JIT compiler compiles the bytecode into JVM executable machine code. I'm not about to dig any deeper... Java is platform independent for the same reason ionCube PHP is independent LOL. Bytecode is bytecode, and although it isn't source, it isn't fully compiled code either.

    So (adding something to the thread...) what are the current Java issues:


    Security

    The Java platform provides a security architecture which is designed to allow the user to run untrusted bytecode in a "sandboxed" manner to protect against malicious or poorly written software. This "sandboxing" feature is intended to protect the user by restricting access to certain platform features and APIs which could be exploited by malware, such as accessing the local filesystem, running arbitrary commands, or accessing communication networks.

    In recent years, researchers have discovered numerous security flaws in some widely used Java implementations, including Oracle's, which allow untrusted code to bypass the sandboxing mechanism, exposing users to malicious attacks. These flaws affect only Java applications which execute arbitrary untrusted bytecode, such as web browser plugins that run Java applets downloaded from public websites. Applications where the user trusts, and has full control over, all Java code being executed are unaffected.

    On August 31, 2012, Java 6 and 7 on Microsoft Windows, Mac OS X, and Linux were found to have a serious security flaw that allowed a remote exploit to take place by simply loading a malicious web page. Java 5 was later found to be flawed as well.

    On January 10, 2013, three computer specialists spoke out against Java, telling Reuters that it was not secure and that people should disable Java. Jaime Blasco, Labs Manager with AlienVault Labs stated that "Java is a mess. It?s not secure. You have to disable it."This vulnerability affects Java 7 and it is unclear if it affects Java 6, so it is suggested that consumers disable it. Security alerts from Oracle announce schedules of critical security-related patches to Java.

    On January 14, 2013, security experts said that the update still failed to protect PCs from attack. This exploit hole prompted a response from the United States Department of Homeland Security encouraging users to disable or uninstall Java. Apple blacklisted Java in limited order for all computers running its Mac OS X operating system through a virus protection program.
     
  17. mateomatrix

    mateomatrix Newbie

    Joined:
    Apr 23, 2016
    Messages:
    14
    Likes Received:
    1
    Well, what is your question? :D