Understanding Java Binary Incompatibility

Hi folks,
I'm just reading up about binary imcompatibility for a software engineering exam and having a hard time understanding the notes. Is anyone able to provide an understandable definition. I understand that the problem comes from having different classes at compile time than at runtime, but I'm trying to understand why this affects Java and not other languages, such as C.
any input is much appreciated

the simplest example I can think of is when a class changes its interface between versions. so you have
1) MyClass.java is compiled to MyClass.class with a public method a()
2) Client.java is compiled to Client.class that calls method a()
3) MyClass.java is recompiled without Client.java present, having removed a() and replaced it by b()
4) Client.class is run, the new MyClass.class is loaded and the JVM detects that a() is not found in MyClass.class's definition. This is not necessarily reported until Client attempts to call a()
http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.html#44952
asjf

Similar Messages

  • When instructed "the java binary in your path"

    please help
    when Im instructed with the following:
    a JDK or JRE 1.0+ (see www.javasoft.com) installed and the java binary in your PATH
    my operating system is windows server 2000
    how do i set the path to to the java binary, Is the java binary. Is the java binary the bin folder, if so i have two of those, one directly under the jdk folder and one under jre folder.
    Do i use autoexecute.bat, if so how.
    thank you for any help rendered.
    Yaary

    Oh oh.
    Java uses the sys var CLASSPATH to look for - well - java classes.
    For that reason, CLASSPATH should always include ".;<yourJavaDir>\jre\lib\rt.jar" or ".;<yourJavaDir>\j2re1.4.x\lib\rt.jar". This ensures that Java can find the classes that come with the distribution (i.e. everything in rt.jar) and all classes in the directory from which you invoke Java or Javac.
    Now, the "<yourJavaDir>\jdk1.x.x\bin" thingie belongs into your PATH variable - that's the var your system uses to look for executables, i.e. java or javac.
    Regards, Thomas

  • Understanding java multithread programming

    Hi
    I am new to java multithreaded programming.
    In order to understand more about threading mechanism, I would like to first know more about the processors,operating systems.
    Please let me know which book or web site to follow to get a brief but good idea about processors,operating systems that would eventually let me go further with the understanding of multithreading mechanism in java.
    Any input is highly appreciated.
    Thanks in advance.

    Multithread programming is a difficult topic.
    If you protect every access to shared memory by using synchronized methods, you are on the safe side.
    But things are not so simple in the real world.
    Sooner or later, you will face deadlock problems, for instance, and you will learn how to avoid them.
    With more experience, you will be tempted to use some "tricks" that you will find on the internet ( double-locking idiom or things like that ), not understanding why it is dangerous and does not work.
    If you continue your investigation, you will end up with concepts such as memory barrier, race conditions, spinlocks, mutexes, memory model, processor cache and SMP, instruction reordering, and more.
    ( google some of these topics how wide the landscape is )
    In fact, the more you work with it, the more you will have questions about it, and the more you will want to learn about it.
    I also thought that multithreading was easy, three years ago, but it is not true.
    Today, I continue to read books about it.
    Read a lot ! The topic is wide, but the more you know about it, the best you can use it and be confident with it !
    It is worth the effort, as multithreading is here to stay and seems to be everywhere.
    Multithreading is difficult to understand fully, but very interesting.
    Besides, if you write code for server programs ( serving multiple clients ), you must be aware of it.
    Eventually, you will perhaps read this book:
    UNIX(R) Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers
    by Curt Schimmel
    It is not about java, but if you want to really understand java, you must learn about the underlying layers, and even how a processor works.
    As an example of what not to do and that I saw in an introductory book about java, the following code is full of bugs and does not work !
    You cannot stop the looping thread B by just setting and testing a global flag like that.
    static int stopflag = 0;
    Thread A:
    public void stop_B_thread()
    stopflag = 1;
    Thread B:
    while (stopflag == 0)
    // do some job

  • How to read non-java binary file?

    Hello Team,
    I have problem to read non-java binary file.
    Let me explain.... I have one binary file created in vc++ having fix structure. Structure of file is like String,int,int,int.
    Now I have to read this file in my java application. I am failed to identify length of String value of Structure in java.
    Can any body help me to solve this problem?
    Thanks in advance.
    - Pathik

    Thanks for guide me,
    I have try using 0x00. And its working.
    Now I have another problem:
    in file.ext , I have written one record having structure string,int and int.
    I have enter data as "HelloWorld", 100 and 111.
    To read first record from file file.ext, following code I am using:
    try
         FileInputStream fis = new FileInputStream("file.ext");
         DataInputStream in = new DataInputStream(fis);
         char ch;
         while((ch=(char)in.readByte()) != 0x00)
              System.out.print(ch+"");
    System.out.println();
         System.out.println("Integer 1 --> " + in.readInt());
         System.out.println("Integer 2 --> " + in.readInt());
         in.close();
         fis.close();
    catch(Exception ex)
         System.out.println(ex.toString());
    And I am getting following output:
    HelloWorld
    Integer 1 --> 0
    Integer 2 --> 0
    File file.ext is created in vc++
    I am not getting integer data. Plz guide me for this problem.
    Thanks in advance
    - Pathik

  • Convert LRAW to java binary

    this question should be asked in ABAP session,
    nevertheless, because no one answer at that section,
    LRAW have length 1024
    FunctionName : YEMM_ATTACHMENT
    COL_NAME DATA_TYPE LENGTH
    FILE_NAME : CHAR 200
    TLINENO: CHAR 4
    CONTE: LRAW 1024
    in java i can just using this
    byte[] attachfile= file.getBytes();
    if a file is bigger than 1024 , how do i store it and pass it to JCO..
    do i have to pass line by line of binary code ??
    JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");
    ByteArrayOutputStream byteBuffer=new ByteArrayOutputStream();
    if(blnAttach.equalsIgnoreCase("x")==true){            
    if(inputAttach.getNumRows()>0){
    int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
    for(int k=0;k<lineno;k++){
    fileName=inputAttach.getString("FILE_NAME");
    file=inputAttach.getByteArray("ATTACHMENT");
    ByteBuffer.write(file);
    OutMailDetailsBean outMailDet=new OutMailDetailsBean();
    outMailDet.setAttachment(ByteBuffer.toByteArray()); 
    outMailDet.setAttachmentId(getAttachmentId());
    outMailDet.setAttachmentName(fileName);
    outMailDet.setEmailId(emailId);
    beanList2.add(outMailDet);            
    1) while converting the file ...i download it and open it....
    when open, i always get file corrupted , although the file size is same as the original file
    any idea ?
    ABAP LRAW to java binary
    2) This is printed from ABAP
    how to i print the same thing in java and do a comparison i mean the binary code
    Row MANDT FILE_NAME TLINENO CONTE
    1 dsn.jar 1 504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266
    2 dsn.jar 2 E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B
    3 dsn.jar 3 75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8
    4 dsn.jar 4 FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571
    5 dsn.jar 5 8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E
    6 dsn.jar 6 348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000
    7 dsn.jar 7 E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C
    8 dsn.jar 8 A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039
    9 dsn.jar 9 CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B
    10 dsn.jar 10 2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8
    11 dsn.jar 11 34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696
    Message was edited by:
            yzme yzme

    Hi yzme
    http://www.apentia-forum.de/viewtopic.php?t=1962&sid=9ac1506bdb153c14edaf891300bfde25
    Hope if answers to your question.
    Regards
    Divya

  • LRAW to java binary

    LRAW have length 1024
    FunctionName : YEMM_ATTACHMENT
    COL_NAME DATA_TYPE LENGTH
    FILE_NAME : CHAR 200
    TLINENO: CHAR 4
    CONTE: LRAW 1024
    in java i can just using this
    byte[] attachfile= file.getBytes();
    if a file is bigger than 1024 , how do i store it and pass it to JCO..
    do i have to pass line by line of binary code ??
    JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");
    ByteArrayOutputStream byteBuffer=new ByteArrayOutputStream();
    if(blnAttach.equalsIgnoreCase("x")==true){            
    if(inputAttach.getNumRows()>0){
    int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
    for(int k=0;k<lineno;k++){
    fileName=inputAttach.getString("FILE_NAME");
    file=inputAttach.getByteArray("ATTACHMENT");
    ByteBuffer.write(file);
    OutMailDetailsBean outMailDet=new OutMailDetailsBean();
    outMailDet.setAttachment(ByteBuffer.toByteArray()); 
    outMailDet.setAttachmentId(getAttachmentId());
    outMailDet.setAttachmentName(fileName);
    outMailDet.setEmailId(emailId);
    beanList2.add(outMailDet);            
    1) while converting the file ...i download it and open it....
    when open, i always get file corrupted , although the file size is same as the original file
    any idea ?
    ABAP LRAW to java binary
    2) This is printed from ABAP
    how to i print the same thing in java and do a comparison i mean the binary code
    Row MANDT FILE_NAME TLINENO CONTE
    1 dsn.jar 1 504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266
    2 dsn.jar 2 E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B
    3 dsn.jar 3 75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8
    4 dsn.jar 4 FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571
    5 dsn.jar 5 8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E
    6 dsn.jar 6 348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000
    7 dsn.jar 7 E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C
    8 dsn.jar 8 A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039
    9 dsn.jar 9 CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B
    10 dsn.jar 10 2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8
    11 dsn.jar 11 34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696
    Message was edited by:
    yzme yzme>

    Hi yzme
    http://www.apentia-forum.de/viewtopic.php?t=1962&sid=9ac1506bdb153c14edaf891300bfde25
    Hope if answers to your question.
    Regards
    Divya

  • Do week-long java courses help to understand java &  get a job?

    i tried searching for this topic before posting, but "courses" "classes" & "instruction" come up with a lot that has nothing to do with the topic at hand. :)
    like many others, i'm teaching myself out of a book (Deitel). so far i've been able to understand the material and create programs based on the exercises. however, i'm now into the meat of OOP with superclass, subclasses, how they interact and the like and i'm having a rough go of it. i can diagram and understand the abstract concept, but when i'm faced with an actual program example i have a difficult time following the interactions between classes.
    i'm considering taking one of those 5 day classes, but am wary of how much they will actually be able to cover in detail (not to mention the $$). has anyone here taken one of those classes and found them to be of great benefit to learning the OOP portion of Java? did it give you enough understanding to obtain an entry-level job?
    btw, i'm doing a pro bono project for a small company to get some real world experience. (i've heard that suggestion many times in regards to obtaining one's "experience" w/o a job)
    thank you all very much for your help.

    I took a week long course to learn Java. It worked I did learn the basics of Java but I did already know how to program in C and VB at the time. I found the AWT section of the class to be very valuable,cosidering I mostly write GUI. And the concepts of AWT mostly all apply to swing so that didn't set me back at all. Depending on the school it may help you to understand OOP. But be careful because most schools progress the class at the skill level of the majorty. So if you have 15 people in the class and 9 of them know nothing about programing your probably going to spend the week learning what a variable and a while loop do, you all pay the same tuition and they would rather 6 of you leave then 9 of you leave. If you have some prior programming knowledge I would recomend finding a class that caters to that.

  • Trying to understand java

    Trying to understand corba
    please tell me what the inout in this coode means:
    boolean book_search(inout b_item book, inout client olvas) raises (BookNoAvail)
    The type of parameter passing in Java is that it makes a copy of the parameter and themn in method somthing happens??
    So which one is it out of the two: pass by reference and pass by value?

    please tell me what the inout in this coode means:A parameter that supplies input as well as accepts output is an INOUT parameter.

  • Trying to understand Java servers

    I have been trying to get an understanding of Java ServerSockets and have hit a dead-end here.
    This is just the first part of the server code and I can't see what the compiler does not like about this. The compiler dies and puts the arrow on the "a" of the word accept. I have looked at lots of different examples of server codes and no 2 resources have the same way of doing it.
    Does anyone have any idea first of all what is wrong with mine below and
    what it should be?
    thanks
    George Mizzell
    import java.net.*;
    import java.io.*;
    public class STServer {
    public static void main (String[] args) throws IOException {
    if (args.length != 1) {
    System.err.println("Oops, invalid parameters");
    return;
    Socket client = accept (Integer.parseInt (args[0]));
    try {

    I apologize for not including the rest of the code. As a newbie, I was thinking that the code processed sequentially and the lines after the problem did not play a role in causing the compile error. Here is the complete listing.
    Thanks for reading it and pointing this out
    import java.net.*;
    import java.io.*;
    public class STServer {
    public static void main (String[] args) throws IOException {
    //test for correct number of parameters - ie must enter a port number
    if (args.length != 1) {
         System.err.println("Oops, invalid parameters");
         return;
         Socket client = accept (Integer.parseInt (args[0]));
         try {
              InputStream in = client.getInputStream ();
              OutputStream out = client.getOutputStream ();
              out.write("Welcome to the Echo Server.\r\n".getBytes("latin1"));
              PrintWriter p;
              PrintWriter ToClient = new PrintWriter(client.getOutputStream());
              String UserName = System.getProperty("user.name");
              String sendtext;
              sendtext = "You are now connected to " + UserName + ".\r\n";
              out.write ("You are now connected to the Echo Server.\r\n"
         .getBytes ("latin1"));
              out.write (sendtext.getBytes ("latin1"));     
              int x;
              while ((x = in.read ()) > -1)
         out.write (x);
              } finally {
                   System.out.println ("Closing");
                   client.close ();          
              System.out.println ("Starting on port " + args[0]);
              System.out.println ("Waiting");
              System.out.println ("Accepted from " + client.getInetAddress ());
              EchoServer5.close ();
         } catch (IOException e) {
              System.out.println("Port did not accept connection:" +
                   Integer.parseInt (args[0]));
         System.exit(-1);
    }

  • Trying to understand Java Sockets

    First, I have been able to find enough examples to get off ground zero and now I need a little help understanding what I have found.
    Secondly, I have a problem that i need a little help on.
    First - as I understand it the // indicates a comment and then I found a snippet that helped me get what I wanted but I can't understand this
         } catch(IOException e) {
         e.printStackTrace();
         // System.exit(3);
    return;
    in this is example is the //System.exit(3) doing anything or is it just intended as a comment? What does the return do? Where does it return to?
    Secondly - the problem. In setting up the socket, I am trying to trap for a few common errors such as parameter not entered on the command line, invalid host, invalid port, or port not listening, etc. Some of these I have been able to figure out because people have examples that help me figure out how to use it but others don't. Here is my code snippet so far. I am trying to explore the PortUnreachableEception class and haven't had any success at all. Where would it go and what would be the right way to use it in this scenario?
    Thanks
    George Mizzell
    import java.io.*;
    import java.net.*;
    public class GetBoth3{
    public static final int GetDayTimePort = 13;
    public static final int GetQuotePort = 17;
    public static void main(String[] args){
         if (args.length != 1) {
         System.err.println("Oops, no address to find");
         // System.exit(1);
         return;
         InetAddress address = null;
         try {
         address = InetAddress.getByName(args[0]);
         } catch(UnknownHostException e) {
         e.printStackTrace();
         // System.exit(2);
    return;
         Socket getDateTime = null;
         try {
         getDateTime = new Socket(address, GetDayTimePort);
         } catch(IOException e) {
         e.printStackTrace();
         // System.exit(3);
    return;
         InputStream in = null;
         try {
         in = getDateTime.getInputStream();
         } catch(IOException e) {
         e.printStackTrace();
         // System.exit(5);
    return;
         BufferedReader reader = new BufferedReader(new InputStreamReader(in));
         String line = null;
         try {
         line = reader.readLine();
         } catch(IOException e) {
         e.printStackTrace();
         // System.exit(6);
    return;
         System.out.println("The current date and time on " + address + " is " + line);
         // System.exit(0);
    return;
    } // GetBoth3

    Starting with your first question:
    } catch(IOException e) {
    e.printStackTrace();
    // System.exit(3);
    return;
    System.exit(3) is commented out there, it is not doing anything. At first it seems confusing because... why write a line of code, then comment it out? Does it tell us anything? What's going on? The reason that it's commented out is either because the original programmer put System.exit(3) there and decided to use return instead, but didn't want to forget what the original line of code was, or, he wanted to suggest to the reader that perhaps System.exit(3) may be more appropriate than return. Sometimes, when I am debugging an application I wrote, I comment out lines of code without deleting them, so that I won't forget what they were. Or, I comment out my debugging code so that I can easily use it again later without it being compiled into release versions.
    So, to answer your question. The //System.exit(3) does nothing, it is just intended as a comment. Return causes the flow of execution to jump out of the method that it is currently in and return to the calling method. For example:
        public static void main (String[] args) {
            System.out.println("Calling poo(true):");
            poo(true);
            System.out.println("Calling poo(false):");
            poo(false);
            System.out.println("Sorry, no more poo.");
        public static void poo (boolean do_return) {
            System.out.println("First line.");
            if (do_return) return;
            System.out.println("Second line.");
        };The output should be:
        Calling poo(true):
        First line.
        Calling poo(false):
        First line.
        Second line.
        Sorry, no more poo.I don't know if any of that works, I just typed it here. But, you should be able to see what I'm getting at. If do_return is true in poo, then the return statement causes poo to RETURN to main (which is the function that poo was called from) before printing "Second line.".
    By contrast, if I would have put System.exit(3) in poo() instead of return, then after calling poo(true) and printing "First line.", the program would have exited back to the system, and "Calling poo(false):" would never have been printed.
    So, in the code that you typed, in GetBoth3.main:
    if (args.length != 1) {
    System.err.println("Oops, no address to find");
    // System.exit(1);
    return;
    Putting a commented out //System.exit(1) does nothing in your program, it's just a comment. When ever you use "return" from main, since nothing called main, returning from main just exits the program and returns to the system.
    So:
    1) Use return in a method to stop executing the rest of the code in the method, and exit the method.
    2) Use return in main() to end the program. This is the same as typing System.exit(0) in main.
    3) Use System.exit(code) anywhere in your program to end the program at any given time.
    Note that the following code:
        public myMethod () {
            // Do some things...
            if (some_expression == true) return;
            // Do some more things....
        };is functionally equivalent to:
        public myMethod () {
            // Do some things...
            if (some_expression != true) {
                // Do some more things...
        };But the first one is a bit easier to read, esp. when your code gets more complex.
    Here is my code snippet so far. I am trying to explore the
    PortUnreachableEception class and haven't had any success at all.
    Where would it go and what would be the right way to use it in this
    scenario?
    If you look at the class derivation tree at the top of the javadoc page for PortUnreachableException, you see that one of the classes it is derived from is IOException. Whenever you use a try...catch block, not only does "catch" catch whatever type of exception you specify, but it also catches all exception classes DERIVED from the one that you specified. So, by catching an IOException, you are, in fact, also catching PortUnreachableExceptions. The problem is, in this code...
        try {
            getDateTime = new Socket(address, GetDayTimePort);
        } catch (IOException iox) {
            System.out.println("Error: " + iox);
            System.exit(0);
        };...although you are catching an IOException (and PortUnreachableException's) as well, you have no clean way of differentiating between PortUnreachableException and any other IOException in your code (except by using instanceof, which I can explain later if you want, but it's not really the preferred way to do it in this case).
    You could try the following exception handler instead:
        try {
            getDateTime = new Socket(address, GetDayTimePort);
        } catch (PortUnreachableException px) {
            // Stuff
        };But then you will get an uncaught exception compiler error, because the Socket constructor throws an IOException, and you are only catching a subset of exceptions derived from IOException, so any other exceptions besides PortUnreachableException (and the exceptions derived from PortUnreachableException) will remain uncaught by your exception handler.
    The solution is to catch both, like so:
        try {
            getDateTime = new Socket(address, GetDayTimePort);
        } catch (PortUnreachableException px) {
            System.out.println("Invalid port specified!");
            System.exit(some_exit_code);
        } catch (IOException iox) {
            System.out.println("Error creating socket: " + iox);
            System.exit(some_exit_code);
        };Note that the order in which your catch statements appear is important. If an exception is thrown in the try block, the program will go to each catch block in order, and execute the first one that applies. So, since PortUnreachableException is derived from IOException, and can therefore be caught by IOException catch blocks, the following code will not do what you want:
        try {
            getDateTime = new Socket(address, GetDayTimePort);
        } catch (IOException iox) {
            System.out.println("Error creating socket: " + iox);
            System.exit(some_exit_code);
        } catch (PortUnreachableException px) {
            System.out.println("Invalid port specified!");
            System.exit(some_exit_code);
        };Since the IOException catch block appears first, and since PortUnreachableExceptions can be caught be IOException catch blocks, then the IOException catch block code will execute, not the PortUnreachableException catch block code.
    Also, you may be confused about a few other things I threw in my code:
    First of all, "some_exit_code" is whatever exit code you want. The exit code you use does not directly affect your application in any way. Exit codes are useful if you say, spawn your application from another process, and then you want the spawning process to be able to know some information about how your application exited. I can explain that better too, if you want.
    Secondly, I used System.exit() instead of return in the main() exception handlers just so that I could control the exit code of the application. If you have no use for exit codes, just use return from main. Also, keep in mind, if you use System.exit() in ANOTHER method (not main) instead of return, then you will exit the program rather than returning from the method.
    Also, System.out.println("Error: " + iox) will print a good amount of detail about the IOException iox. Although it won't be as useful as printStackTrace() to you, the developer, it will be more readable than printStackTrace() to the common user.
    As an aside, relating to System.out.println, if you define the following method in one of your classes:
        public String toString () {
            return "A string representation of this class.";
        };Then you can use System.out.println(MyClass), or String i = "Description: " + MyClass to print readable information about MyClass. I didn't explain that well so here is an example:
        // OddEven.java
        public class OddEven {
            protected int i;
            public OddEven (int i) {
                this.i = i;
            public String toString () {
                if ((i % 2) == 0) return "even number";
                else return "odd number";
        // Whatever.java
        public class Whatever {
            public static void main (String[] args) {
                OddEven o = new OddEven(31);
                OddEven e = new OddEven(100);
                System.out.println("OddEven o: " + o);
                System.out.println("OddEven e: " + e);
        };That should work, haven't tested it though. But basically, any time an Object gets converted to a String (for example, by passing an Object to a function expecting a String, or by use '+' to concatenate an Object to a String), the toString() method of that Object is called, and the return value is used as the String.
    That example should give you another idea about what return does, too.
    If you want me to explain instanceof, exit codes, or class derivation and inheritance, lemme know.
    Hope any of this helps.
    Jason Cipriani
    [email protected]
    [email protected]

  • Extend Domain to include BPM -- Enterprise manager crashes Java binary

    Hello,
    I thought I would share a rather puzzling issue.  I have been working with a Soa Suite Domain for quite some time now, and have it configured with a java email servers, JMS, Db Adapters, and I wanted to extend this domain so I backed it up and extended it to include BPM.  Later when opening EM, I would suddenly get a message saying that the Java SE Binary had stopped working.
    There are very few mentions on the net for weblogic, this one being the only one I could find JAVA (TM) Platform SE Binary Stopped Working on SOA Enterprise manager
    In my case, it turns out that I had an email server that was using one version of java, while the domain was working on the java version in the installation directory.  I went to the control panel, system, environmental variables and took the path of the java that the email server was using, and entered in the java version of the weblogic domain.  No problems so far....
    Stuart

    Looks like you have conflict with your java home and you are running 2 different JREs. Keep the latest and try launching EM console again and post the exception if you get any.
    Thanks,
    Vijay

  • Java binary search and insert

    I'm currently writing a program which is an appointment book. I currently have 4 classes and at the minute it can sort the array and print it out. I'm stuck at binary search and inserting a new appointment record. I will include the classes which i have got.
    Appointment
       import java.util.*;
       import java.io.*;
       import java.util.Scanner;
        class Appointment implements Comparable
          private String description;
          private int day;
          private int month;
          private int year;
          private String startTime;
          private String endTime;
          protected static Scanner keyboard = new Scanner(System.in);     
           public Appointment()
             description = "";
             day = 0;
             month = 0;;
             year = 0;;
             startTime = "";
             endTime = "";
           public Appointment(String appDesc, int appDay, int appMonth, int appYear, String appStartTime, String appEndTime)
             description = appDesc;
             day = appDay;
             month = appMonth;
             year = appYear;
             startTime = appStartTime;
             endTime = appEndTime;
           public void display()      
             System.out.print("  Description: " + description);
             System.out.print(", Date: " + day + "/" +month+ "/" +year);
             System.out.println(", Start Time: " + startTime);
             System.out.println(", End Time: " + endTime);
           public void setDay(int day)
          { this.day = day; }
           public int getDay()     
             return day; }
           public void setMonth(int month)
          { this.month = month; }
           public int getMonth()     
             return month; }
           public void setYear(int year)
          { this.year = year; }
           public int getYear()
             return year; }
           public int compareTo(Object obj)
             if (obj instanceof Appointment)
                Appointment appt = (Appointment) obj;
                if (this.day > appt.getDay())
                   return 1;
                else if (this.day < appt.getDay());
                return -1;
             return 0;
           public String toString() {
             StringBuffer buffer = new StringBuffer();
             buffer.append("Description: " + description);
             buffer.append(", Date: " + day + "/" +month+ "/" +year);
             buffer.append(", Start Time: " + startTime);
             buffer.append(", End Time: " + endTime);
             return buffer.toString();
           public void read(){
             System.out.print("Description : ");String descIn=keyboard.next();
             System.out.print("Day : ");int dayIn=keyboard.nextInt();
             System.out.print("Month : ");int monthIn=keyboard.nextInt();
             System.out.print("Year : ");int yearIn=keyboard.nextInt();
             System.out.print("Start Time : ");String startIn=keyboard.next();
             System.out.print("End Time : ");String endIn=keyboard.next();
             boolean goodInput = false;
             do{          
                try{
                   setDay(dayIn);
                   setMonth(monthIn);
                   setYear(yearIn);
                   goodInput = true;
                    catch(IllegalArgumentException e){
                      System.out.println("INVALID ARGUMENT PASSED FOR day or month or year");
                      System.out.println(e);
                      System.out.print("RE-ENTER VALID ARGUMENT FOR DAY : ");dayIn=keyboard.nextInt();
                      System.out.print("RE-ENTER VALID ARGUMENT FOR MONTH : ");monthIn=keyboard.nextInt();
                      System.out.print("RE-ENTER VALID ARGUMENT FOR YEAR : ");yearIn=keyboard.nextInt();                                        
             }while(!goodInput);
       }

    Array
    import java.util.*;
    class Array
         private Appointment[] app;
         private int nElems;
         Appointment tempApp;
         public Array(int max)
              app = new Appointment[max];
              nElems = 0;
         public Array(String desc, int day, int month, int year, String sTime, String eTime)
              app = new Appointment[100];
              nElems = 0;
       public int size()
          { return nElems; }
         void add(){
              Appointment appointmentToAdd = new Appointment();
              // Read its details
              appointmentToAdd.read();
              // And add it to the studentList
              //app[nElems].add(appointmentToAdd);
         public void add(String desc, int day, int month, int year, String sTime, String eTime)
            app[nElems] = new Appointment(desc, day, month, year, sTime, eTime);
            nElems++;             // increment size
              Appointment appointmentToAdd = new Appointment(desc, day, month, year, sTime, eTime);
              // And add it to the studentList
              //app[nElems].add(appointmentToAdd);
          public void insert(Appointment tempApp) {
        int j;
        for (j = 0; j < nElems; j++)
          // find where it goes
          if (app[j] > tempApp) // (linear search)
            break;
        for (int k = nElems; k > j; k--)
          // move bigger ones up
          app[k] = app[k - 1];
        app[j] = tempApp; // insert it
        nElems++; // increment size
       public void display()       // displays array contents
            for(int j=0; j<nElems; j++)    // for each element,
              app[j].display();     // display it
            System.out.println("");
         public void insertionSort()
       int in, out;
       for(out=1; out<nElems; out++) // out is dividing line
         Appointment temp = app[out];    // remove marked person
         in = out;          // start shifting at out
         while(in>0 &&        // until smaller one found,
            app[in-1].getMonth().compareTo(temp.getMonth())>0)
          app[in] = app[in-1];     // shift item to the right
          --in;          // go left one position
         app[in] = temp;        // insert marked item
         } // end for
       } // end insertionSort()
    }Menu
    import java.util.*;
    class Menu{
       private static Scanner keyboard = new Scanner(System.in);
       int option;
         Menu(){
            option=0;
         void display(){
              // Clear the screen
            System.out.println("\n1 Display");
              System.out.println("\n2 Insert");          
              System.out.println("3 Quit");          
         int readOption(){
            System.out.print("Enter Option [1|2|3] : ");
              option=keyboard.nextInt();
              return option;
    }Tester
       import java.util.*;
       import java.util.Arrays;
        class ObjectSortApp
           public static void main(String[] args)
                   int maxSize = 100;
                   Array arr;
                   arr = new Array(maxSize)
                   Appointment app1 = new Appointment("College Closed", 30, 4, 2009, "09:30", "05:30");;
                   Appointment app2 = new Appointment("Assignment Due", 25, 4, 2009, "09:30", "05:30");
             Appointment app3 = new Appointment("College Closed", 17, 4, 2009, "09:30", "05:30");
             Appointment app4 = new Appointment("Easter Break", 9, 4, 2009, "01:30", "05:30");
             Appointment app5 = new Appointment("College Opens", 15, 4, 2009, "09:30", "05:30");
             Appointment app6 = new Appointment("Assignment Due", 12, 4, 2009, "09:30", "05:30");
             Appointment app7 = new Appointment("Exams Begin", 11, 4, 2009, "09:30", "05:30");
                //To sort them we create an array which is passed to the Arrays.sort()
            //method.
            Appointment[] appArray = new Appointment[] {app1, app2, app3, app4, app5, app6, app7};
             System.out.println("Before sorting:");
            //Print out the unsorted array
            for (Appointment app : appArray)
                System.out.println(app.toString()); 
                Arrays.sort(appArray);
             //arr.insertionSort();      // insertion-sort them
             System.out.println("\n\nAfter sorting:");               
            //Print out the sorted array
            for (Appointment app : appArray)
                System.out.println(app.toString());
              Menu appMenu = new Menu();
              int chosenOption;
              do{
                 appMenu.display();
                   chosenOption=appMenu.readOption();
                   for (Appointment app : appArray)
                   switch(chosenOption){
                      case 1 : app.display(); break;
                        case 2 : arr.add(); break;
                        default:;
              }while(chosenOption != 3);    
          } // end main()
       } // end class ObjectSortApp

  • Understanding Java Class Accessibility

    I don't understand what makes a Java library class accessible by a Java applet. If an applet has an import statement that imports, say, java.util.TreeMap, then when a web browser accesses a web page containing that applet, does it download the Java code for the TreeMap class at that time, and if so, does that mean that you have to package the TreeMap class as part of your applet class code somehow? Or, must the TreeMap class be installed as part of the Java virtual machine on the computer that is running the browser? If the latter, what determines whether or not the typical computer will have the TreeMap class available? Is the TreeMap class available on a PC running Windows XP, using the Java virtual machine that Microsoft supplies? Where can I read about this sort of thing? How can I determine what classes I can safely use if I want my applet to run on both Windows and Macs?

    "I don't understand what makes a Java library class accessible by a Java applet. If an applet has an import statement that imports, say, java.util.TreeMap, then when a web browser accesses a web page containing that applet, does it download the Java code for the TreeMap class at that time, and if so, does that mean that you have to package the TreeMap class as part of your applet class code somehow? "
    No.
    "Or, must the TreeMap class be installed as part of the Java virtual machine on the computer that is running the browser?"
    Yes
    "If the latter, what determines whether or not the typical computer will have the TreeMap class available?"
    The version of the Java Runtime environment/Plug-in installled on the PC
    "Is the TreeMap class available on a PC running Windows XP, using the Java virtual machine that Microsoft supplies?"
    No which why some people don't use the newer Java classes or Swing when they write applets.
    "Where can I read about this sort of thing? How can I determine what classes I can safely use if I want my applet to run on both Windows and Macs?"
    http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html

  • Understanding java.lang.RuntimePermission

    I was utilizing a script I found online which allows me to call OS commands and PERL scripts from PL/SQL, using JAVA as an interface. Before things would work, the following DBMS_JAVA calls were necessary.
    I think I get the last one (file permissions) but I don't understand the purpose of the first 2.
    EXEC dbms_java.grant_permission('SHARED', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC dbms_java.grant_permission('SHARED', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    EXEC dbms_java.grant_permission('SHARED', 'SYS:java.io.FilePermission', '/bin/sh', 'execute');
    I mainly concerned as they look like they grant read/write privileges on everything (...'writeFileDescriptor', ''). java.sun.com warns that "[readFileDescriptor] ... would allow code to read the particular file associated with the file descriptor read. This is dangerous if the file contains confidential data", and that "[writeFileDescriptor]...allows code to write to a particular file associated with the descriptor. This is dangerous because it may allow malicious code to plant viruses or at the very least, fill up your entire disk."
    So I'm concerned,
    Chuck

    We have since taken it that step further, and revoked access to /bin/sh, and granted it to a test PERL script /test/scripts/list_dir.pl
    What is strange is that when I went out to the operating system today (Sep 16) and issued a 'ps -ef' I found the following:
    [oracle@ora4 oracle]$ ps -ef | grep 5994
    oracle 5994 1 0 Sep15 ? 00:10:52 ora_s001_dev
    oracle 11214 5994 0 Sep15 ? 00:00:00 [list_dir.pl <defunct>]
    oracle 11327 5994 0 Sep15 ? 00:00:00 [ls <defunct>]
    oracle 16866 14478 0 07:56 pts/0 00:00:00 grep 5994
    The processes are hanging around (I started with a more simple 'ls' just to see if this would even work - so it's there too).
    Why would that be?
    If it helps, here is the java code and the PL/SQL wrapper that I found at orafaq.com:
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1) {
    finalCommand = new String[4];
    finalCommand[0] = "C:\\winnt\\system32\\cmd.exe";
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    } else {                              // Linux or Unix System
    finalCommand = new String[3];
    finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    // Execute the command...
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    // Capture output from STDOUT...
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("stdout: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    } catch (IOException ioe) {
    System.out.println("Error printing process output.");
    ioe.printStackTrace();
    } finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    // Capture output from STDERR...
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("stderr: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    } catch (IOException ioe) {
    System.out.println("Error printing execution errors.");
    ioe.printStackTrace();
    } finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    show errors
    rem -----------------------------------------------------------------------
    rem Publish the Java call to PL/SQL...
    rem -----------------------------------------------------------------------
    CREATE OR REPLACE PROCEDURE host (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    /

  • Understanding Java 3D

    Alright, so I am quite new to Java. Actually, no I am not 'new' to it... I've been trying to understand it for quite sometime now.
    Could someone please correct this if I am wrong:
    In order to build applications in Java, I must first use an IDE (netbeans, eclipse, etc.)
    Now lets say, I am building a Java Tetris as a way to get familiar with Java. Well now my question is...
    For example I am somewhat literate of how game development works on the 'outside' of Java, but now when I come into Java it is like a whole new world.
    Now my question is, lets say I want to 'strategically' place some Tetris blocks in the 'dropping' area of Tetris. Is there anyway to actually see it...
    For example on game engines you can change the X Y Z axis of an object. Is Java 3D a game engine?
    For example, is there a GUI (graphical user interface) to see what I am doing when I am making a game?
    Edited by: Triz on Oct 27, 2007 3:56 AM

    Actually, Java 3D is not exactly a game engine (if you are looking for a java game engine, try to look at www.jmonkeyengine.com).
    Java 3D is a scene graph-based 3D application programming interface (API) for the Java platform. It runs on top of either OpenGL or Direct3D. You can use Java3D to add some good stuff to your applications, and also to create games.
    But if you are planning to use or create games with some "special" features, you should try a game engine like jME (jMonkey Engine).

Maybe you are looking for

  • Error 7 came up when updating itunes, told to reinstall but 'apple mobile device' failed to start, check privileges? what does this mean?

    when trying to update itunes error 7 appeared and a message to reinstall. have tried to dowload again but now 'apple mobile device' failed to start, verify you have sufficient privileges? Anyone know what this means. do I ignore?

  • How I fixed Time Machine

    I was having problems with Time Machine, just like many people in here. Slow transfers, error in the middle of the process. Here's how I fixed it: 1. In System Preferences>Time Machine, turn off backups (the On/Off switch). 2. In Disk Utility, select

  • Alert for Marketing Attributes

    Hi I am sorry but I donu2019t understand the solution presents in the last questions on this issue. I am using CRM 2007 and I have marketing attributes maintained on the Sold-to party business partner. I want this marketing attribute to be displayed

  • 13" and 1440x900 WXGA+

    Hello, The idea about what I am going to ask came from a friend of mine who succesfully replaced his XGA screen for SXGA without any difficulty on his Asus laptop. I want to ask about the compatibility between displays – is there any standardized kin

  • Hub Usd for use with External Drive

    Hi everyone. I`d like to connect 4 things in my MacBook Pro, but i have only 2 USB`s Ports. So, I think about buy a Hub Usb like this - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=260509760536&ssPageName=ADME: X:RTQ:US:1123 - Can i using this