Java - Platform Independent, so why different results?

This isn't a code specific topic, but I hope someone can still help me out with this. I've been developing a bit of code for a Java class that I'm taking, working in a small group with a few friends. I spend an entire weekend pounding out a GUI for this project, and upon completion, test it thoroughly and agressively, absolutely TRYING to get it to crash. Once I'm satisified it's got more safety features than a Volvo, I pass it along to my friend and ask him to play with it a little and see what happens.
Well, suffice to say he gets COMPLETELY different results. The layout of the GUI is the same, but on his side, when the code executes to remove a JLabel, it removes a couple of others with it. Upon staring at my code for hours, doing handwritten walk-throughs of the code itself, and doing more staring at the code, I can't understand for the life of me what's causing this. On my side, the one JLabel disappears just fine, reappears when the code is executed to restore it. On his side, multiple JLabels disappear, and refuse to reappear.
I've tried changing it from setting them to disappear to setting them to setText("") and turn white. The same thing happens... multiple JLabels turn white and remove their text.
The only common denominator I can get out of this is that his machines (he's tested more than one) are all multi-core systems (dual core or quad core), where mine is single core. Even then, I see nothing in the code that even if it were threaded should cause this to happen. The functions are extremely specific. Still, I'll confess to not knowing a THING about threading, could this have something to do with it? I can post some code if that would help, but there's quite a bit of it...

I don't currently have my code available, but I've got a pseudocode outline of what's supposed to be happening, if that will help any... if not, sorry for just cluttering things up... >_>
In response to the JLabel array quesiton, I have an X x Y sized grid made of JLabels, dynamically drawn based on user input (how many rows and how many columns they want). While those are in an array, they're not involved in this part of the process...
The way this works is the project is a simulation of an assembly line on a shop floor. There are four types of mahcines, called BodyAttacher, Painter, InteriorAssembler, Wrapper, and Conveyor. There can only be one BodyAttacher, Painter, InteriorAssember, and Painter. Conveyors are essentially unlimited. There is a JLabel for each of these machines labeled with the name of that machine. Each one is setText to their class name. To ensure the user can ONLY place one of the first four machines, the code below kicks in. For simplicity's sake, I've included only the mouselistener for the BodyAttacher and the function that it calls, because they all do the same thing (except for a different instance of a machine).
The method that happens when the user does this goes like this:
//      This is done from memory, and I couldn't remember all of the code
//      exactly, so any parts that have glaring errors (like the name of the
//      mouse listener and the reference to event) because these probably
//      aren't right.
Machine newMachine = null;  // this is used to hold new machines as they are
                                           // created before they are attached to the line.
// This is the mouse listener for the BodyAttacherLabel
public void BodyAttacherLabelMouseClicked(java.awt.event evt) {
         JLabel tempMachineLabel = evt.getSource();  // store the source of which label was clicked on.
         if (tempMachineLabel.isEnabled()) {
                 newMachine = new BodyAttacher();
                 disableMachineLabel(tempMachineLabel);
         tempMachineLabel = null;   // ensure no other calls accidentally access this label
// This is the method to disable the button
public void disableMachineLabel(Label temp) {
        temp.setEnabled(false);
        temp.setText("");
}This was done from memory, and probably isn't even syntactically correct but it gives an idea of how this works. Could screwy threading be causing disableMachineLabel to execute on more than one Label or something? I can't imagine why or how it would, but I don't know much about threading...

Similar Messages

  • 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).

  • Why different result for the same jsp file run at oc4j902 and oc4j903?

    In a jsp file, It use class in "java.util" package, It is not import "java.util.*".
    The jsp file run at oc4j 902:
    It run correctly
    The jsp file run at oc4j 903:
    appear Compile error.
    the error is:
    "OracleJSP: oracle.jsp.provider.JspCompileException: "
    The jsp file:
    &lt;%@ page contentType="text/html;charset=GB2312"%&gt;
    &lt;%
         ArrayList arrList = new ArrayList();
    %&gt;
    Why?
    thanks for your help!

    Sun,
    pls check
    http://otn.oracle.com/docs/products/ias/doc_library/903doc_otn/generic.903/a97679/getstart.htm#1007970
    In 902, the following packages were also imported
    java.io.*
    java.util.*
    java.lang.reflect.*
    java.beans.*
    In 903 the above are not imported.
    -Prasad

  • 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 ?

  • Different results of an store procedure

    Hi everyone,
    I have a partitioned table (by day of the week) and an store procedure that selects some records from a especific partition (that one that represents "today").
    Inside Oracle client I get the result I'm expecting, but when I call the procedure from a java client I get a different result (it searches in another partition).
    Any ideas?? if you need some code let me know.
    Thanks in advance,
    Charlie Garcia.

    Well, partitioned by day of the week means the column is declared as?
    I'm assuming there's a bind mismatch between the defined value in the table, and what you are passing in to the routine.
    So for example, your table is partitioned on a date column and you pass in a string to your stored routine. Then Oracle has to do a conversion for you (if it can) and compare the value you passed in, to the converted value.
    for example, if you pass in '01-05-01' as a string, what date would you say that is?
    ME_XE?select to_date('01-05-03', 'dd-mm-yy') from dual;
    TO_DATE('01-05-03','DD-MM-
    01-MAY-2003 12 00:00
    1 row selected.
    Elapsed: 00:00:00.00
    ME_XE?select to_date('01-05-03', 'mm-dd-yy') from dual;
    TO_DATE('01-05-03','MM-DD-
    05-JAN-2003 12 00:00
    1 row selected.
    Elapsed: 00:00:00.01
    ME_XE?select to_date('01-05-03', 'yy-dd-mm') from dual;
    TO_DATE('01-05-03','YY-DD-
    05-MAR-2001 12 00:00
    1 row selected.

  • 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

  • Why java is called platform independent

    Hello
    Why java is called as platform independent?Any body please give a detailed explanation since im a beginner to java technology.
    ThankYou
    Jk

    BigDaddyLoveHandles wrote:
    georgemc wrote:
    SunFred wrote:
    Java is not platform independent since it depends on the Java platform ;)Don't complicate matters!I always thought the phrase should have been "platform agnostic"It's a phrase I've used meself

  • 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 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.

  • Java-puzzlers...Why 2 different outputs for the same line

    Here, why it is giving 2 different outputs for the same set of lines
    Line-1 and Line-2 are both same.But giving 2 different results ???
    /*java-puzzlers*/
    public class Elementary {
        public static void main(String[] args) {
             System.out.println(12345 + 5432l);  /*Line-1: Original statement- didn't modify*/
          System.out.println(12345 + 54321);  /*Line-2: I wrote - I delete 12345 + 54321 and wrote the same thing again*/
    }

    kjshikal wrote:
    one of them is a longkjshikal,
    For the third and final time. Please stop resurrecting old threads like this.
    Thank you for your co-operation.

  • 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.

  • 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?

  • Determining free disk space in a platform independent "java-like" way?

    how can i determine free disk space in a platform independent "java-like" way?

    Search the forum "free disk space".

  • 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.

  • Clearing network cache worked; ONCE. This is ONLY on facebook. Two users on computer (win 7 Prof), same browswer, both use Facebook. Different results. Why would clearing cache work once??

    Windows 7 professional. Firefox 6.02
    Only on Facebook.
    Yet 2 users on computer and 2 different results. I have already uploaded a screen shot. I see more and more users are reporting this, but many more are probably not.

    In general theory, one now has the Edit button for their posts, until someone/anyone Replies to it. I've had Edit available for weeks, as opposed to the old forum's ~ 30 mins.
    That, however, is in theory. I've posted, and immediately seen something that needed editing, only to find NO Replies, yet the Edit button is no longer available, only seconds later. Still, in that same thread, I'd have the Edit button from older posts, to which there had also been no Replies even after several days/weeks. Found one that had to be over a month old, and Edit was still there.
    Do not know the why/how of this behavior. At first, I thought that maybe there WAS a Reply, that "ate" my Edit button, but had not Refreshed on my screen. Refresh still showed no Replies, just no Edit either. In those cases, I just Reply and mention the [Edit].
    Also, it seems that the buttons get very scrambled at times, and Refresh does not always clear that up. I end up clicking where I "think" the right button should be and hope for the best. Seems that when the buttons do bunch up they can appear at random around the page, often three atop one another, and maybe one way the heck out in left-field.
    While I'm on a role, it would be nice to be able to switch between Flattened and Threaded Views on the fly. Each has a use, and having to go to Options and then come back down to the thread is a very slow process. Jive is probably incapable of this, but I can dream.
    Hunt

Maybe you are looking for