Is Java Byte Code is 100% platform independent

Hi all
A my room fellow is disturbing me about the platform independency of JAVA.
Now i only wan to know that generated Byte Code will be same if it is generated on different platforms (Window,Linux,Unix etc)using their respected JVM
Thanks in advance

The "Platform Independency" of Java is a bit of a joke
to me. You need a JVM that is platform dependent to
run it. Now granted, you can write one application
and itll run on any platform, but that's only assuming
they have the JVM installed on them. Not to say that
Java isn't cool and all, but the "platform
independency" solution still has a reliance on
something that is platform dependent... It's like
driving an automatic and saying you can drive....Sure,
you are making the car go, but something is doing the
shifting for you....(C: I guess I'm just arguing for
the sake of arguing...Well if you want to argue that point then no language is platform independant. C code for instance needs a compiler for the platform you want to compile it to run on and that compiled code won't work on any other platform. Ultimately every program has something that ties it to a particular platform, that's just the nature of things in computers.
The idea of platform independance was the removal of the need to re-compile a program with a native compiler just to get it to run on that platform.
Instead Sun opted to have a compact JVM to interpert the byte code and have the byte code standard across all implementations of the JVM.

Similar Messages

  • Java byte code spec

    Hi, I'm interested in learning more about Java byte codes, but I can't find any kind of specification or other document describing them. Do you know where I could find such document?

    Hi,
    it's here
    http://java.sun.com/docs/books/jls/index.html
    Download is available at the bottom of that page
    greetings Marsian

  • Java Byte Code --- Normal Java Code(Text)

    I m making an application IDE(C/C++) for Java, In this I want to give Option to convert Java Byte Code to Normal Java Code(Text).........For This tell me how to do it.

    See the page
    http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javap.html
    for a description of javap.exe, the Java class file disassembler.

  • Java byte code

    recently i came across an idea where a it read something about changing a SVG file into java byte code. can anyone give me idea about what i means and what are the applications for someone to do such a thing. i thing just flew right over my head, does anyone have any idea about this at all.
    thanks

    As I recall, there is a xml standard for SVG files. You don't change SVG files into byte code directly. Instead, you interpret the file and create objects. e.g.
    public Shape[] getShapesFromSVGFile(File f) throws IOException;
    Then draw them like any other shape.

  • Platform independency

    I have developed an implementation of High Availability Servers using Java in Linux. But the problem is it runs only in Linux because I have used the System class to execute a native OS command "ipconfig eth0 192.168.0.0.123" to change the Ip of the system.Is there any way to go around this so that the code becomes purely platform independent?
    One option is to detect the OS that is currently running and execue the appropriate System command using a switch statement.So is it possible to detect the underlying OS?If so , what is the command for changing IP in Mac OS, Windows....and any others which u can think of.
    HELP.

    Here is some basic code I wrote a LONG time ago:
         public static final int OSTYPE_WINDOWS = 1;
         public static final int OSTYPE_WINNT = 2;
         public static final int OSTYPE_WINCE = 3;
         public static final int OSTYPE_LINUX = 4;
         public static final int OSTYPE_MAC = 5;
         public static final int OSTYPE_SOLARIS = 6;
         public static final int OSTYPE_NETWARE = 7;
         public static final int OSTYPE_OS2 = 8;
         public static final int OSTYPE_UNKNOWN = 9;
         private static int type = OSTYPE_UNKNOWN;
              @return an integer identifying the OS (one of the OSTYPE constants)
         public static int getOs()
              if(type == OSTYPE_UNKNOWN){
                   String osname = System.getProperty("os.name").toLowerCase();
                   if(osname.indexOf("windows") != -1){
                        if(osname.indexOf("nt") != -1 || osname.indexOf("2000") != -1 || osname.indexOf("xp") != -1){
                             type = OSTYPE_WINNT;
                        } else if(osname.indexOf("ce") != -1){
                             type = OSTYPE_WINCE;
                        } else {
                             type = OSTYPE_WINDOWS;
                   } else if(osname.indexOf("linux") != -1 || osname.indexOf("bsd") != -1){
                        type = OSTYPE_LINUX;     
                   } else if(osname.indexOf("mac os") != -1 || osname.indexOf("macos") != -1){
                        type = OSTYPE_MAC;
                   } else if(osname.indexOf("solaris") != -1){
                        type = OSTYPE_SOLARIS;     // could also be old freebsd version
                   } else if(osname.indexOf("netware") != -1){
                        type = OSTYPE_NETWARE;
                   } else if(osname.indexOf("os/2") != -1){
                        type = OSTYPE_OS2;
                   } else {
                        type = OSTYPE_UNKNOWN;     
              return type;
         }

  • Question about compiled byte code

    Howdy folks,
    I have a client who wants to run an application in both
    on-line and off-line modes. The user could run the application
    locally on their laptop making changes and such which would get
    stored to local database files (probably FoxPro free tables just to
    make it easier on me). Then when the user got back to their
    internet connection they could run the application and it would
    sync with the online tables (probably MySql tables at that point).
    So the question is, if I compile Cold Fusion code into Java
    byte code, will it be able to execute independantly of the Cold
    Fusion Server? I realize that I could load ColdFusion on the user's
    laptop, but I don't think I want to do that. I'm assuming that the
    answer to my question will be "No. You can't do that. Cold Fusion
    isn't meant to work like that." To which my next question would be,
    "Well, what language would be best for the type of application I
    have described above? Action Script, maybe?"
    Any thoughts are welcome, especially if you've written an
    application like the one I've described.
    Thanks very much,
    Chris

    Well, rats.
    I wrote a nice reply to your message BKBK, but lost it
    because, apparently, my session timed out.
    The basic jist, was that I've been working on AJAX, and have
    been implementing some AJAX-like techniques at some other clients
    (using hidden iframes combined with innerHTML -- I know not a
    standard, but darn handy otherwise), but I couldn't see how that
    would solve my on-line/off-line problem (unless I stuck with the
    cookies idea).
    I also did some reading on cookies last night (obviously, I
    don't use cookies very often if at all in my daily coding), and I'm
    a bit put off by the different browser limitations. I'd hate my
    client to be chugging along, entering appointments into the
    "database" (read: data being stored as cookies to be sync'd later
    when the user goes online), and then suddenly run into the cookie
    limitation. On top of that, if I'm reading right, IE (my client's
    most likely choise of browser), will not let you know that you've
    reached this limit, but will just begin dropping the older cookies
    in favor of the newer ones. If I could programmatically sense this
    limitation and then write the cookies to some file before
    continuing that'd be geat, but since JavaScript can't write files
    (that I know of) this isn't feasable. Also, if I could write a file
    like that, I wouldn't bother with the cookies.
    I think I'm going to end up writing it in FoxPro since my
    company has a bunch of copies of it (and it's licenced per
    developer and not per copy), and there are lots of folks in my
    company who can help me get up to speed. That also means that I'll
    probably need to write a web version of the code for when my
    client's client's (does that make sense? :-) ) connect to the app
    via the internet.
    Anyway, I'm really enjoying everyones comments on the
    subject. Can anybody think of a technique for a way around the
    cookie limitations? Or perhaps another language that this whole
    thing could be written in?
    I really wish that I could compile my ColdFusion code for use
    independant of the CF server. I know, that's not the way it works
    and typically not what scripting languages like this are used for.
    I suppose I could always install the developer's version of CF on
    the user's local machine, write the code in CF and then just detect
    whether or not the user is online and behave accordingly.

  • Platform Independent , Reality or Myth

    Does Java Platform independent in reality ??
    Or in reality Java is a combination of Platform Independent Complier with Platform Dependent Interpreter !!!!

    After checking out the link
    http://java.sun.com/docs/books/tutorial/getStarted/int
    ro/definition.html
    We can conclude at the same point which I raised
    earlier ,i.e , Platform Independent Compiler with
    Platform dependent Interpreter (JVM).the compiler is not platform independent, the code it produces is though
    can't you see the difference ? you don't have to recompile your code to port it to another environment, you just have to make sure that the JVM is installed in this environment
    think about applets, the advantage may seem clearer

  • Executing tiny programming language compiled byte code with the JVM

    Hello,
    For a project, I am developing a simple programming language, with a syntax not unlike Pascal, which compiles to Java Byte Code. Currently I execute the compiled byte code using my own interpreter. This works OK, but what I'd like to do now is to execute the compiled byte code using the actual existing JVM. The compiled byte code resides in a text file upon compilation of a sample program written in my tiny programming language. Does anyone know how I may start to go about this? Thanks in advance.
    adam

    The only way of getting a standard Java virtual machine to execute your java byte code, is to wrap it up into a completely valid java class file.
    Any constants you use, must be put into the classes constant pool.
    Any local variables will have to go into the local variable table of the method which uses them... etc, etc.
    Something like ASM, would let you dynamically create a Java class file.
    http://asm.objectweb.org/
    regards,
    Owen

  • Java Decompiler Code

    Hi,
    im a fresher in java
    im trying to develop my own java decompiler which translates class file to java file ,can anyone help me please how to start and give some guidelines .. wud b really helpful
    looking forward for your support .. thanks !!

    A decompiler is a very advanced project to take on, not for a "fresher".
    1. You must write a disassembler first.
    This involves being able to parse the binary class file, and convert it into java
    byte code instructions.
    As mentioned, the class file format is documented here, and is the sole reference I needed to write a disassembler.
    http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html
    2. After you have the disassembled instructions, you can then try to reassemble
    them into higher level java source code.
    This isn't a trivial project.
    In my free time, I spent ( on and off ), 1 year writing my own disassembler to support Java 1.5, and I haven't even attempted a decompiler ( yet ).
    It has 279 classes, most fairly complex.
    Just to give you an idea of my experience, 7 years java, 5 years C++ and assembly. And you'll need some experience/concepts of assembly language to work out the stack frame to break the java byte code instructions into java statements.
    In my opinion, you're better off experimenting with the BCEL ( byte code engineering lab ), to extract details about the class file.
    regards,
    Owen

  • Need platform independent java code for TNS PING

    Hi, I am able to ping server /ip address. but unable to ping some TNS entry.
    There is one way to ping TNS entry using System command, but that will make my code platform dependent. i want platform independent code.. need code help for TNS Ping to database server.. here are my code:
    ---Code for server / Ip address ping:---------
    package DBM;
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.UnknownHostException;
    import java.util.ArrayList;
    import oracle.net.TNSAddress.*;
    public class PingServer
    public static void main(String[] args)
    System.out.println(" Server Pinging Starts...");
    ArrayList<String> list=new ArrayList<String>();
    list.add("g5u0660c.atlanta.hp.com");
    list.add("g1u1675c.austin.hp.com");
    list.add("gvu1785.atlanta.hp.com");
    list.add("10.130.14.109");
    list.add("10.130.0.173");
    list.add("DESCRIPTION = (SDU = 32768) (enable = broken) (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = gvu1515.atlanta.hp.com)(PORT = 1525))(ADDRESS = (PROTOCOL = TCP)(HOST = gvu1785.atlanta.hp.com)(PORT = 1525)");
    list.add("IDSENGI");
    //This Ipadd variable is used to convert the arraylist into String
    String ipadd="";
    try
         for(String s: list)
              ipadd=s;
              // InetAddress is class.in this class getByName()is used to take only string parameter.
              InetAddress inet = InetAddress.getByName(ipadd);
              //InetAddress inet1 =InetAddress.getAllByName("IDESENGP");
              System.out.println("Sending Ping Request to " + ipadd);
              //in InetAddress call IsReachabe(3000)method is used to ping the server IP and if ping is successfully then return true otherwise false.
              //IsReachable()take time in millisecond and return type is boolean.
              System.out.println("Host is reachable: "+inet.isReachable(3000));
         System.out.println("Server Pinging program is working fine........");
    catch (UnknownHostException e)
         System.err.println("Host does not exists");
    catch (IOException e)
         System.err.println("Error in reaching the Host");
    ----Code for TNS ping using system host----
    package DBM;
    import java.io.*;
    public class doscmd
    public static void main(String args[])
    try
    Process p=Runtime.getRuntime().exec("cmd /c tnsping IDSENGP");
    p.waitFor();
    BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line=reader.readLine();
    while(line!=null)
    System.out.println(line);
    line=reader.readLine();
    catch(IOException e1) {}
    catch(InterruptedException e2) {}
    System.out.println("Done");
    The above two codes are working absolutely fine... but need TNS ping program is platform dependent..we need to deploy it in both windows, unix...
    Please help.

    You don't need to install another JDK, just use the api from 1.2 and you should be fine. You can even use the 1.4 jdk to compile as if it were 1.2 by using the -target option in javac.

  • Why java is called platform independent? "write once, run anywhere" code...

    I do have a answer for this. Please shed some light whether i am right or wrong.
    When you say java as platform independent, it means that, any java program once compiled to java class can be transferred to anyother machine(say, from windows to unix) can be executed, provided the destination machine has JVM.
    where as, in C/C++, if we transfer the object files from one machine to another machine, they will not be executed and they have to be re-compiled in the other machine.
    Am i correct?
    please, do give me your idea on this...
    thanks...

    Thanks george !

  • Java platform independent.what is a platform?

    This question has been haunting me for a long time.
    When we say Java is platform independent,what does the term platform
    indicate?
    I think it is Processor+Operating System.
    But people talk only of Operating System as platform.
    A processor has its own instruction set that is different from that of other processors.An executable code on one processor doesn't run on another processor,whatever may be the operating system.
    Java code is platform independent because it is just compiled to byte code and that byte code is interpreted and run on a JVM.Here the JVM is different for different platforms.
    My question is:
    consider two platforms:
    Intel Pentium+MS Windows.
    and AMD Athlon+MS Windows.
    Is the same JVM used for both these platforms?or not?WHY?
    If only Operating System is Considered as platform,what happens to the underlying processor?

    <troll style="flamesuit: on;">Java is not plateform inderpendent, java runs on one plateform, the Java Platform.</troll>
    The "Intel / AMD + MS Windows" is two forks of one plateform, the x86 / Windows plateform.
    You could extends the x86/Windows JVM to include Intel extras in such a way that it would not run on AMD/Windows.
    One way you could define a plateform is as a binary format, processor intuction set and public API.
    So java == .class format, bytecode and the java.* packages
    and Linux x86 == ELF, x86 and POSIX (plus others, such as X)
    and FreeBSD x86 == ELF, x86 and POSIX (plus others, such as X)
    and Cygwin == ELF, x86 and POSIX (plus others, such as X)
    and Windowsx86 == PE, x86, MFCs
    But does that mean Linux, FreeBSD and Cygwin are the same plateform, well kind-of, they are all unix-sqe, and in some cases the binarys are interchangable (a small plug in to FreeBSD will let you run Linux software, the same sort of thing is aviable to Solaris, and some very small (hello world-level) will actually run (I've seen this in the case of a Linux HelloWorld on a BeOS machine).

  • Java is   NOT   Platform Independent ????????

    Hai.
    My friend told ...
    we can able to say java is platform independent.
    but
    in one company (software anaylist) ask
    talk about java is not platform independent...
    so how its possible..
    plz i want clear cuts...
    even i search in google also.. but i cant get clearlly.........
    yours
    advance happy pongal and upcomming festivals
    drvijayy2k2

    >
    A quick example I recently encountered of platform
    dependence was in character encoding/decoding. Have
    a look at how Solaris, Linux and Windows print out
    the full range of bytes when they are encoded as
    Strings. There are lots of little differences, happy
    discovering.This is a good illustration. By default java uses the character encoding which it believes to be in general use on the platform it's running on, but you can specify the character encoding explicitly. So, by default, the Java program addapts it's exact behaviour to the platform.
    Is "a platform independant" program one which produces the same file format on systems which will interpret that file format different ways? Or is it one that generates a file format that will produce equivalent results on two different systems?
    There's a similar dilema with "look and feel" (i.e. window gadgets etc.). Should a platform independant program use the same look and feel on systems whose native look and feel is different, or should it "blend in"?
    Java leaves these choices to the programmer.

  • Why java is platform independent ?

    what is the meaning of java is platform independent ? is it just because of java code can be run in windows/linux/unix platform ? but then C/C++ also can be run in windows/linux/unix . so why those are not called platform independent ?
    why java is called platform independent ?

    c/c++ creates object code . similary java creates bytecode . java uses interpreter JVM to execute . similary c/c++ object code also executes in any platform. so where is the real difference ?
    the classes do not need to be recompiled for different platforms. what do u mean by this ? ".....classes ( i.e bytecode) dont need recompilation ..." .....ok....but same thing is true for C/C++ object code also !! they also dont need recompilation.
    where is the difference ?

  • How do u say java is platform independent

    how do u say java is platform independent.....when a .class file for a program cannot be executed in another system with no java installed in it.......

    Pictograms are language independent (sort of)
    do you expect them to work in the land of the blind?

Maybe you are looking for