Listening socket class freezes my program

i originaly created a listening socket in my main gui class but everytime i execute it, my gui appears with no visible components inside and freezes. i am not able to close the gui window by clicking on the x button at teh top right hand corner.
i then removed my listening socket and made a new class altogether that listens to socket connection. i get the same problem when i execute both my gui and listening socket class. any suggestions?
heres my socket listening class
package icomm;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class listening {
    /** Creates a new instance of listening */
    public listening() {
     public void listeningSocket()
            ServerSocket server = null;
            boolean listening = true;
            try
                //listen in port 4444;
                server = new ServerSocket(14);
            catch(IOException x)
                JOptionPane.showMessageDialog(null, "cannot listen to port 4444", null, JOptionPane.ERROR_MESSAGE);
            while(true)
                 ChatDialog w;
                try
                  w = new ChatDialog(server.accept());
                  Thread t = new Thread(w);
                  w.setVisible(true);
                  t.start();
                 // server.close();
                catch(IOException x)
                    JOptionPane.showMessageDialog(null, "could not open chat window", null, JOptionPane.ERROR_MESSAGE);
}and here is the code that launches the gui and the listening class from my login button..
//laod main gui
                    show_main_gui(text_username.getText());
                    //run listening socket
                    listening listen = new listening();
                    listen.listeningSocket();

you do not need any thread for this - the socket will not block your frame. here is an example which works:
import java.net.ServerSocket;
import javax.swing.JFrame;
public class Sockframe extends JFrame{
     public Sockframe(){
       super("Socket using Application");
       setDefaultCloseOperation(EXIT_ON_CLOSE);
       setSize(100,100);
      * @param args
     public static void main(String[] args) {
          // show new Frame
          Sockframe f = new Sockframe();
          f.setVisible(true);
          try{
               // do socket stuff
               ServerSocket s = new ServerSocket(4567);
               s.accept();
          } catch(Exception exc){
               exc.printStackTrace();
}Did you provide some default close operation for the frame? The frame needs this to know how to behave when the X-button os pressed.

Similar Messages

  • The connect function in the socket class has problems

    when i call this function connect(SocketAddress endpoint, int timeout)
    the timeout variable doesnt wait for the specific time that i tell it
    example
    connect(endpoint, 10000);
    this call should wait for this amount of time but it doesnt wait that amount
    any body has a answer ???

    yes that is exactly what I am saying
    I specify 10 sec, as 10000 milli sec's in the connect function but I get an exception almost imediately when i run my java program...
    run this code
    import java.net.*;
    public class Test
    public static void main(String [] args)
    { Socket s = null;
    int port = 2000;
    try
    s = new Socket();
    InetSocketAddress i = new InetSocketAddress("localhost",port);
    //this next line should wait 10 sec's then throw and exception
    //but it throws and exception upon running the this code
    s.connect(i,10000);
    catch(Exception e){ System.out.println(e.toString()); }
    }//main
    }//Test
    I have also tried setting the setSoTimeout(10000) in the Socket class but
    still with no success...
    I dont know why this doesnt wait 10 sec's then through an exception on it
    and when i try it with a java server it connects instantly...
    any help anyone???

  • I have files that freeze my programs whenever I try to open ANY file. Is there a way to find the exact files causing the crash?

    I have files that are freezing my programs (adobe; after effect and photoshop, as well as maxon cinema 4d). Whenever I try to import ANY file from within the program it doen't even let me select the file I need before freezing. I have moved all files off my desktop and into my dropbox, and it now allows me to import files/search for files on the desktop but NOT dropbox, once I go to dropbox it freezes again. I am assuming there are files within dropbox now that are crashing my programs. The problem is I have a lot of files in there and would like to remove the corrupt ones so that I can use my programs without freezing. Is there a way to find the exact files causing the crash?
    This has happened a couple of times and each time I have to move all my files off my desktop, so there must be a type of file doing this, I just don't know what files they are.
    Mac Book Pro 15" running OSX 10.9
    Processor  2.3 GHz Intel Core i7
    Memory  16 GB 1600 MHz DDR3
    Graphics  Intel Iris Pro 1024 MB
    ANY help would be greatly appreciated! It is making it really hard to get work done. THANKS!

    This error sounds to me like you have/had BootCamp Windows installed and then removed, posible ?
    If so (and even if not so), try restating your MBA while holding down the alt/option-key until you get to the Boot Selection Screen.
    Choose to boot OSX.
    Once in OSX go to System Preferences then Startup Volume and set your OSX to be the default.
    Hope it helps
    Stefan

  • Need to create a driver class for a program i have made...

    hey guys im new to these forums and someone told me that i could get help on here if i get in a bind...my problem is that i need help creating a driver class for a program that i have created and i dont know what to do. i need to know how to do this is because my professor told us after i was 2/3 done my project that we need at least 2 class files for our project, so i need at least 2 class files for it to run... my program is as follows:
    p.s might be kinda messy, might need to put it into a text editor
    Cipher.java
    This program encodes and decodes text strings using a cipher that
    can be specified by the user.
    import java.io.*;
    public class Cipher
    public static void printID()
    // output program ID
    System.out.println ("*********************");
    System.out.println ("* Cipher *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* CS 181-03 *");
    System.out.println ("*********************");
    public static void printMenu()
    // output menu
    System.out.println("\n\n****************************" +
    "\n* 1. Set cipher code. *" +
    "\n* 2. Encode text. *" +
    "\n* 3. Decode coded text. *" +
    "\n* 4. Exit the program *" +
    "\n****************************");
    public static String getText(BufferedReader input, String prompt)
    throws IOException
    // prompt the user and get their response
    System.out.print(prompt);
    return input.readLine();
    public static int getInteger(BufferedReader input, String prompt)
    throws IOException
    // prompt and get response from user
    String text = getText(input, prompt);
    // convert it to an integer
    return (new Integer(text).intValue());
    public static String encode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String encoded = ""; // base for string to return
    char letter; // letter being processed
    // convert message to upper case
    original = original.toUpperCase();
    // process each character of the message
    for (int index = 0; index < original.length(); index++)
    // get the letter and determine whether or not to
    // add the cipher value
    letter = original.charAt(index);
    if (letter >='A' && letter <= 'Z')
    // is A-Z, so add offset
    // determine whether result will be out of A-Z range
    if ((letter + offset) > 'Z') // need to wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE + offset);
    else
    if ((letter + offset) < 'A') // need to wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE + offset);
    else
    letter = (char) (letter + offset);
    // build encoded message string
    encoded = encoded + letter;
    return encoded;
    public static String decode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String decoded = ""; // base for string to return
    char letter; // letter being processed
    // make original message upper case
    original = original.toUpperCase();
    // process each letter of message
    for (int index = 0; index < original.length(); index++)
    // get letter and determine whether to subtract cipher value
    letter = original.charAt(index);
    if (letter >= 'A' && letter <= 'Z')
    // is A-Z, so subtract cipher value
    // determine whether result will be out of A-Z range
    if ((letter - offset) < 'A') // wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE - offset);
    else
    if ((letter - offset) > 'Z') // wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE - offset);
    else
    letter = (char) (letter - offset);
    // build decoded message
    decoded = decoded + letter;
    return decoded;
    // main controls flow throughout the program, presenting a
    // menu of options the user.
    public static void main (String[] args) throws IOException
    // declare constants
    final String PROMPT_CHOICE = "Enter your choice: ";
    final String PROMPT_VALID = "\nYou must enter a number between 1" +
    " and 4 to indicate your selection.\n";
    final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
    "cipher: ";
    final String PROMPT_ENCODE = "\nEnter the text to encode: ";
    final String PROMPT_DECODE = "\nEnter the text to decode: ";
    final String SET_STR = "1"; // selection of 1 at main menu
    final String ENCODE_STR = "2"; // selection of 2 at main menu
    final String DECODE_STR = "3"; // selection of 3 at main menu
    final String EXIT_STR = "4"; // selection of 4 at main menu
    final int SET = 1; // menu choice 1
    final int ENCODE = 2; // menu choice 2
    final int DECODE =3; // menu choice 4
    final int EXIT = 4; // menu choice 3
    final int ALPHABET_SIZE = 26; // number of elements in alphabet
    // declare variables
    boolean finished = false; // whether or not to exit program
    String text; // input string read from keyboard
    int choice; // menu choice selected
    int offset = 0; // caesar cipher offset
    // declare and instantiate input objects
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    // Display program identification
    printID();
    // until the user selects the exit option, display the menu
    // and respond to the choice
    do
    // Display menu of options
    printMenu();
    // Prompt user for an option and read input
    text = getText(input, PROMPT_CHOICE);
    // While selection is not valid, prompt for correct info
    while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
    !text.equals(EXIT_STR) && !text.equals(DECODE_STR))
    text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
    // convert choice to an integer
    choice = new Integer(text).intValue();
    // respond to the choice selected
    switch(choice)
    case SET:
         // get the cipher value from the user and constrain to
    // -25..0..25
    offset = getInteger(input, PROMPT_CIPHER);
    offset %= ALPHABET_SIZE;
    break;
    case ENCODE:
    // get message to encode from user, and encode it using
    // the current cipher value
    text = getText(input, PROMPT_ENCODE);
    text = encode(text, offset);
    System.out.println("Encoded text is: " + text);
    break;
    case DECODE:
    // get message to decode from user, and decode it using
    // the current cipher value
    text = getText(input, PROMPT_DECODE);
    text = decode(text, offset);
    System.out.println("Decoded text is: " + text);
    break;
    case EXIT:
    // set exit flag to true
    finished = true ;
    break;
    } // end of switch on choice
    } while (!finished); // end of outer do loop
    // Thank user
    System.out.println("Thank you for using Cipher for all your" +
    " code breaking and code making needs.");
    }

    My source in code format...sorry guys :)
       Cipher.java
       This program encodes and decodes text strings using a cipher that
       can be specified by the user.
    import java.io.*;
    public class Cipher
       public static void printID()
          // output program ID
          System.out.println ("*********************");
          System.out.println ("*       Cipher      *");
          System.out.println ("*                   *");
          System.out.println ("*                          *");
          System.out.println ("*                   *");
          System.out.println ("*     CS 181-03     *");
          System.out.println ("*********************");
       public static void printMenu()
          // output menu
          System.out.println("\n\n****************************" +
                               "\n*   1. Set cipher code.    *" +
                               "\n*   2. Encode text.        *" +
                               "\n*   3. Decode coded text.  *" +
                               "\n*   4. Exit the program    *" +
                               "\n****************************");
       public static String getText(BufferedReader input, String prompt)
                                           throws IOException
          // prompt the user and get their response
          System.out.print(prompt);
          return input.readLine();
       public static int getInteger(BufferedReader input, String prompt)
                                           throws IOException
          // prompt and get response from user
          String text = getText(input, prompt);
          // convert it to an integer
          return (new Integer(text).intValue());
       public static String encode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String encoded = "";           // base for string to return
          char letter;                   // letter being processed
          // convert message to upper case
          original = original.toUpperCase();
          // process each character of the message
          for (int index = 0; index < original.length(); index++)
             // get the letter and determine whether or not to
             // add the cipher value
             letter = original.charAt(index);
             if (letter >='A' && letter <= 'Z')          
                // is A-Z, so add offset
                // determine whether result will be out of A-Z range
                if ((letter + offset) > 'Z') // need to wrap around to 'A'
                   letter = (char)(letter - ALPHABET_SIZE + offset);
                else
                   if ((letter + offset) < 'A') // need to wrap around to 'Z'
                      letter = (char)(letter + ALPHABET_SIZE + offset);
                   else
                      letter = (char) (letter + offset);
             // build encoded message string
             encoded = encoded + letter;
          return encoded;
       public static String decode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String decoded = "";           // base for string to return
          char letter;                   // letter being processed
          // make original message upper case
          original = original.toUpperCase();
          // process each letter of message
          for (int index = 0; index < original.length(); index++)
             // get letter and determine whether to subtract cipher value
             letter = original.charAt(index);
             if (letter >= 'A' && letter <= 'Z')          
                // is A-Z, so subtract cipher value
                // determine whether result will be out of A-Z range
                if ((letter - offset) < 'A')  // wrap around to 'Z'
                   letter = (char)(letter + ALPHABET_SIZE - offset);
                else
                   if ((letter - offset) > 'Z') // wrap around to 'A'
                      letter = (char)(letter - ALPHABET_SIZE - offset);
                   else
                      letter = (char) (letter - offset);
             // build decoded message
             decoded = decoded + letter;
          return decoded;
       // main controls flow throughout the program, presenting a
       // menu of options the user.
       public static void main (String[] args) throws IOException
         // declare constants
          final String PROMPT_CHOICE = "Enter your choice:  ";
          final String PROMPT_VALID = "\nYou must enter a number between 1" +
                                      " and 4 to indicate your selection.\n";
          final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
                                       "cipher: ";
          final String PROMPT_ENCODE = "\nEnter the text to encode: ";
          final String PROMPT_DECODE = "\nEnter the text to decode: ";
          final String SET_STR = "1";  // selection of 1 at main menu
          final String ENCODE_STR = "2"; // selection of 2 at main menu
          final String DECODE_STR = "3"; // selection of 3 at main menu
          final String EXIT_STR = "4";  // selection of 4 at main menu
          final int SET = 1;            // menu choice 1
          final int ENCODE = 2;         // menu choice 2
          final int DECODE =3;          // menu choice 4
          final int EXIT = 4;           // menu choice 3
          final int ALPHABET_SIZE = 26; // number of elements in alphabet
          // declare variables
          boolean finished = false; // whether or not to exit program
          String text;              // input string read from keyboard
          int choice;               // menu choice selected
          int offset = 0;           // caesar cipher offset
          // declare and instantiate input objects
          InputStreamReader reader = new InputStreamReader(System.in);
          BufferedReader input = new BufferedReader(reader);
          // Display program identification
          printID();
          // until the user selects the exit option, display the menu
          // and respond to the choice
          do
             // Display menu of options
             printMenu(); 
             // Prompt user for an option and read input
             text = getText(input, PROMPT_CHOICE);
             // While selection is not valid, prompt for correct info
             while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
                     !text.equals(EXIT_STR) && !text.equals(DECODE_STR))       
                text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
             // convert choice to an integer
             choice = new Integer(text).intValue();
             // respond to the choice selected
             switch(choice)
                case SET:
                // get the cipher value from the user and constrain to
                   // -25..0..25
                   offset = getInteger(input, PROMPT_CIPHER);
                   offset %= ALPHABET_SIZE;
                   break;
                case ENCODE:
                   // get message to encode from user, and encode it using
                   // the current cipher value
                   text = getText(input, PROMPT_ENCODE);
                   text = encode(text, offset);
                   System.out.println("Encoded text is: " + text);
                   break;
                case DECODE:
                   // get message to decode from user, and decode it using
                   // the current cipher value
                   text = getText(input, PROMPT_DECODE);
                   text = decode(text, offset);
                   System.out.println("Decoded text is: " + text);
                   break;
                case EXIT:
                   // set exit flag to true
                   finished = true ;
                   break;
             } // end of switch on choice
          } while (!finished); // end of outer do loop
          // Thank user
          System.out.println("Thank you for using Cipher for all your" +
                             " code breaking and code making needs.");
    }

  • Changes are not saved under 'listen sockets' - Webserver 6.1 SP2

    Hi all,
    I'm running Webserver 6.1 SP2 on Solaris 9 and face a strange behaviour when I make changes under 'Listen sockets'. I want to enable nearly everything regarding SSL2 and SSL3 to serve older IE browser versions.
    My config is like
    SSL Version 2 - [enabled]
    Use the default set of SSL version 2 ciphers [enabled]
    <here I check every checkbox>
    <also with SSL Version 3 and TLS Ciphers>
    Then I choose OK - "listen sockets edited" - Apply changes - the server gets restarted.
    But when I view my changes again I see that
    SSL Version 2 [enabled] ... (which is ok )
    <but here all following checkboxes are disabled>
    Mmmh, strange.
    Because of that I still can't connect with IE5.0 SSL2, SSL3 enabled (simulating a customer with an older version).
    The error log says "...SSLv2 is on, but no SSLv2 ciphers are enabled. SSLv2 connections will fail."
    But the checkbox for SSL2 is enabled!
    Someone else with this situation??
    Greetings Nick

    It's an admin gui bug you are running into. The admin gui is not making the proper config changes into the server.xml for turning on the SSL2 ciphers.
    Workaround: edit your server.xml file, find the line for SSLPARAMS and look for the ciphers for sslv2 and change all '-' signs to '+' to turn on the sslv2 ciphers.

  • W530 print dialog freezes the program

    Hi,
         For the past two days I have encountered strange issues.
    I am trying to print out documents or images either from MS word, Adobe Photoshop, Adobe acrobat reader or Firefox. No matter which program I use, the moment I click print, the program freezes without bringing up the printing dialog box. I am unable to figure out the issue.
    I have additional issues with MS office where certain functions freeze the program from time to time. For example, when I try to change the font type or size, the program would freeze. This requires me to try  a couple of restarts or a fresh reinstall of the program. I believe these are bugs relating to my laptop as the same programs (from the same discs) are installed on my home desktop and they work flawlessly.
    FYI, I have made the following changes to my W530
    1. I have replaced the original 500GB 7200RPM primary hard disk with 240GB OCZ Vertex4 SSD. The 500GB hard disk has been moved to the CD ROM bay to serve as a 2nd HDD.
    2. I have increased the RAM to 16 GB.
    Apart from these changes it retains the original settings. It runs a Windows 7 64 bit OS.
    Any help to solve this issue is gratefully acknowledged
    Best wishes
    Arul

    Hi, altruist77
    To narrow down the list of possible issues, it may be a good idea to boot the system into Safe Mode and try the same steps as before and see if the issue still occurs. The printers will not load in safe mode, so you would not be able to print to them anyway. But I am curious to see if the print dialog will still make the computer hang.
    To boot into safe mode, either restart your computer or start from a cold boot. Begin tapping F8 at the splash screen and continue to tap the button until a menu appears. One of the options on this menu should be Safe Mode with Networking. Select this option and the computer will boot. Some features are removed from Safe Mode, so the display will likely look very different, but it is normal. Run the steps in this mode and see what happens.
    Best of luck, and let me know how it goes
    Adam
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution!" This will help the rest of the community with similar issues identify the verified solution and benefit from it.

  • I need to send a message via socket from a C program to a Java program

    Hi,
    I need to send a message via socket from a C program to a Java program. The message has three data: a long, an integer and a string.
    How can I put those three fields in a array of bytes in C? How can I extract those same three fields from an array of bytes in java?
    Thanks a lot!

    A few options:
    JNI
    Corba
    Using sockets directly
    take your pick.

  • Could not find the main class: SearchExcel.  Program will exit.  ????

    sekic0429{uabudd_milou}[w10/rbssw/2.0] pwd
    /tmp/MyJava/jexcelapi
    sekic0429{uabudd_milou}[w10/rbssw/2.0] printenv CLASSPATH
    /tmp/MyJava/excelapi:/app/jdk/1.6.0_16/jre/lib:/app/jdk/1.6.0_16/lib
    sekic0429{uabudd_milou}[w10/rbssw/2.0] ls
    build ExcelSearch.java index.html resources SearchExcel.java~ tutorial.html
    docs ExelSearch.java~ jxl.jar SearchExcel.class src workbook.dtd
    ExcelSearch.class formatworkbook.dtd jxlrwtest.xls SearchExcel.java TestSpecification.xls
    sekic0429{uabudd_milou}[w10/rbssw/2.0] javac -extdirs . ExcelSearch.java
    sekic0429{uabudd_milou}[w10/rbssw/2.0]
    sekic0429{uabudd_milou}[w10/rbssw/2.0] java ExcelSearch
    Exception in thread "main" java.lang.NoClassDefFoundError: ExcelSearch
    Caused by: java.lang.ClassNotFoundException: ExcelSearch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: ExcelSearch. Program will exit.
    sekic0429{uabudd_milou}[w10/rbssw/2.0] cat ExcelSearch.java
    import java.io.File;
    import java.io.IOException;
    import java.util.Date;
    import jxl.*;
    import jxl.read.biff.BiffException;
    public class ExcelSearch
    public static void main(String[] args)
    try
    Workbook workbook = Workbook.getWorkbook(new File("TestSpecification.xls"));
    catch (IOException e)
    e.printStackTrace();
    catch (BiffException e)
    e.printStackTrace();
    Regards Peter, hope for answer

    r035198x wrote:
    Where is SearchExcel.class?Excellent question, though I think I spotted a problem with the cp supplied.
    Note the documentation for -cp state (in part)
    For example, if directory foo contains a.jar and b.JAR, then the class path element foo/* is expanded to a A.jar:b.JAR, except that the order of jar files is unspecified.So instead of this..
    java -cp /tmp/MyJava/excelapi:/app/jdk/1.6.0_16/jre/lib:/app/jdk/1.6.0_16/lib SearchExcel..try this..
    java -cp /tmp/MyJava/excelapi/*:/app/jdk/1.6.0_16/jre/lib:/app/jdk/1.6.0_16/lib SearchExcelNotes:
    1) Adding the JRE classes to the classpath should not be necessary, but I left the rest of the cp unaltered to highlight the one specific difference I am suggesting.
    2) When posting code, code snippets, HTML/XML or input/output, please use the code tags. The code tags help retain the indentation and formatting of the sample. To use them, select the sample text and click the CODE button.
    If that still fails, tell us more specifically where the SearchExcel class is by copy/pasting the output (within code tags) of the command..
    prompt>jar -tvf mysearchexcel.jarWhere, of course, you replace 'mysearchexcel.jar' with the actual Jar name it is supposed to be located in.
    Edit 1:
    Changed JavaDocs -> documentation.
    Edited by: AndrewThompson64 on Jan 11, 2010 7:12 PM

  • Get a reference of a local class at another program

    Hello experts! Sorry if this has been asked before, but I couldn't find exactly what I'm searching for.
    Within function-pool MIGO (main program of transaction MIGO), there's a local class LCL_MIGO_KERNEL. This class has the private attribute PT_CHANGE_TAKEIT (which is an internal table).
    During the execution of MIGO, for a certain criteria, I would like to clear the contents of PT_CHANGE_TAKEIT. Since it's a private attibute, I have managed to create a new public method that just clears it. This method was defined and inplemented within ENHANCEMENT SPOTS available all over SAPLMIGO. My method is ZZ_CLEAR_PT_CHANGE_TAKEIT. So far so good.
    Now, I have to call this method. I have found no other ENHANCEMENT SPOTS in SAPLMIGO at a place where I would me able to make the call (eg, don't know if the criteria fits yet).
    Inside BADI MB_MIGO_BADI, method LINE_MODIFY, I have just what I need to know if I should clear PT_CHANGE_TAKEIT.
    However, inside here I don't have access to the instance of class LCL_MIGO_KERNEL (the instance itself is (SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL)
    So far I have managed to get a pointer to the instance with:
      FIELD-SYMBOLS: <lfs_kernel> TYPE ANY.
      ASSIGN ('(SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL')
        TO <lfs_kernel>.
    So I have the instance of the class, but how can I call my method ZZ_CLEAR_PT_CHANGE_TAKEIT?
    The command  call method <lfs_kernel>->zz_clear_pt_change_takeit.
    can't be done because ""<LFS_KERNEL>" is not a reference variable" as the sintax check tells me.
    I have tried stuff like
      CREATE DATA dref TYPE REF TO
                 ('\FUNCTION-POOL=MIGO\CLASS=LCL_MIGO_KERNEL').
      ASSIGN dref->* TO <ref>.
    but nothing works so far.
    I know if LCL_MIGO_KERNEL was a class from SE24 (not a local one), I could just create a field-symbol of that type instead of type ANY and it would work.
    Does anyone have an idea how that can be done?
    Thank you very much!

    I have managed to do what I needed by calling my method from other ENHANCEMENT SPOTS within SAPLMIGO and some extra coding on MB_MIGO_BADI, but unfortunately I couldn't do what I originaly wanted which was to call a method of a local class from another program, something that could be handy in other situations.
    If it's not lack of knowledge by myself and it really can't be done, I think the ABAP OO framework fell just short of having that flexibility, since I can get the field-symbol to point to the instance of the class, but just can't call the method because of syntax issues.
    Thanks!
    Well it seems you already solved, but I got curious and knew how this could be done, so I wanted to prove it and here it is:
    * This would be inside the Function group
    CLASS lcl_kernel DEFINITION.
      PUBLIC SECTION.
        METHODS:
          zz_clear_pt_change_takeit.
    ENDCLASS.                    "lcl_kernel DEFINITION
    CLASS lcl_kernel IMPLEMENTATION.
      METHOD zz_clear_pt_change_takeit.
        WRITE 'Dummy! I do nothing!'.
      ENDMETHOD.                    "zz_clear_pt_change_takeit
    ENDCLASS.                    "lcl_kernel IMPLEMENTATION
    START-OF-SELECTION.
    * This is just to create the reference. It corresponds to
    * (SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL in your example
      DATA: kernel  TYPE REF TO lcl_kernel.
      CREATE OBJECT kernel.
    *----------------- Now your program (which supposedly does not have
    *----------------- access to kernel or even lcl_kernel def)
    *----------------- would begin
      FIELD-SYMBOLS: <lfs_kernel> TYPE ANY.
      DATA: generic_ref           TYPE REF TO object.
      ASSIGN ('KERNEL')
        TO <lfs_kernel>.
      generic_ref = <lfs_kernel>.
      TRY.
          CALL METHOD generic_ref->('ZZ_CLEAR_PT_CHANGE_TAKEIT').
        CATCH cx_sy_dyn_call_illegal_method .
      ENDTRY.
    Apart from that, I wouldn't access a local class this way. There's a reason for blocking the access, one of them being that SAP could change local classes without notice thus breaking your program.

  • Struts 2 - SEVERE: Error configuring application listener of class mailread

    Struts 2 - SEVERE: Error configuring application listener of class mailreader2.ApplicationListener
    Ol�
    Hi
    All
    I'm getting this erro: when I run my app in struts 2, but I don't know what is going on ?
    Someone can help me
    What is going on?
    Thanks
    SEVERE: Error configuring application listener of class mailreader2.ApplicationListener
    java.lang.ClassNotFoundException: mailreader2.ApplicationListener
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3773)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
         at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
         at org.apache.catalina.core.StandardService.start(StandardService.java:516)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Feb 1, 2008 10:46:31 AM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Skipped installing application listeners due to previous error(s)
    Feb 1, 2008 10:46:31 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    Edited by: NetoJose on Feb 1, 2008 5:33 AM

    I think it's not a jar it's a java class on my package take a look, now i don�t know why the problem?
    Look the erro :
    Struts 2 - SEVERE: Error configuring application listener of class mailreader2.ApplicationListener
    this is my package and a java class:
    mailreader2.ApplicationListener
    package mailreader2;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUserDatabase;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;
    import java.io.*;
    public final class ApplicationListener implements ServletContextListener {
    * <p>Appication scope attribute key under which the in-memory version of
    * our database is stored.</p>
    public static final String DATABASE_KEY = "database";
    * <p>Application scope attribute key under which the valid selection
    * items for the protocol property is stored.</p>
    public static final String PROTOCOLS_KEY = "protocols";
    // ------------------------------------------------------ Instance Variables
    * <p>The <code>ServletContext</code> for this web application.</p>
    private ServletContext context = null;
    * The {@link MemoryUserDatabase} object we construct and make available.
    private MemoryUserDatabase database = null;
    * <p>Logging output for this plug in instance.</p>
    private Log log = LogFactory.getLog(this.getClass());
    // ------------------------------------------------------------- Properties
    * <p>The web application resource path of our persistent database storage
    * file.</p>
    private String pathname = "/WEB-INF/database.xml";
    * <p>Return the application resource path to the database.</p>
    * @return application resource path path to the database
    public String getPathname() {
    return (this.pathname);
    * <p>Set the application resource path to the database.</p>
    * @param pathname to the database
    public void setPathname(String pathname) {
    this.pathname = pathname;
    // ------------------------------------------ ServletContextListener Methods
    * <p>Gracefully shut down this database, releasing any resources that
    * were allocated at initialization.</p>
    * @param event ServletContextEvent to process
    public void contextDestroyed(ServletContextEvent event) {
    log.info("Finalizing memory database plug in");
    if (database != null) {
    try {
    database.close();
    } catch (Exception e) {
    log.error("Closing memory database", e);
    context.removeAttribute(DATABASE_KEY);
    context.removeAttribute(PROTOCOLS_KEY);
    database = null;
    context = null;
    * <p>Initialize and load our initial database from persistent
    * storage.</p>
    * @param event The context initialization event
    public void contextInitialized(ServletContextEvent event) {
    log.info("Initializing memory database plug in from '" +
    pathname + "'");
    // Remember our associated ServletContext
    this.context = event.getServletContext();
    // Construct a new database and make it available
    database = new MemoryUserDatabase();
    try {
    String path = calculatePath();
    if (log.isDebugEnabled()) {
    log.debug(" Loading database from '" + path + "'");
    database.setPathname(path);
    database.open();
    } catch (Exception e) {
    log.error("Opening memory database", e);
    throw new IllegalStateException("Cannot load database from '" +
    pathname + "': " + e);
    context.setAttribute(DATABASE_KEY, database);
    // -------------------------------------------------------- Private Methods
    * <p>Calculate and return an absolute pathname to the XML file to contain
    * our persistent storage information.</p>
    * @throws Exception if an input/output error occurs
    private String calculatePath() throws Exception {
    // Can we access the database via file I/O?
    String path = context.getRealPath(pathname);
    if (path != null) {
    return (path);
    // Does a copy of this file already exist in our temporary directory
    File dir = (File)
    context.getAttribute("javax.servlet.context.tempdir");
    File file = new File(dir, "struts-example-database.xml");
    if (file.exists()) {
    return (file.getAbsolutePath());
    // Copy the static resource to a temporary file and return its path
    InputStream is =
    context.getResourceAsStream(pathname);
    BufferedInputStream bis = new BufferedInputStream(is, 1024);
    FileOutputStream os =
    new FileOutputStream(file);
    BufferedOutputStream bos = new BufferedOutputStream(os, 1024);
    byte buffer[] = new byte[1024];
    while (true) {
    int n = bis.read(buffer);
    if (n <= 0) {
    break;
    bos.write(buffer, 0, n);
    bos.close();
    bis.close();
    return (file.getAbsolutePath());
    Edited by: NetoJose on Feb 1, 2008 7:25 AM

  • AffineTransform freezes my program

    I wrote a 2d program that simulates a bunch of rabbits, who run around the screen reproduce etc. When the rabbits move higher up on the screen they are scaled smaller to give a sort of perspective look. I have 3 images for left animation, 3 for up, 3 for down. When the rabbits are facing right, I scale them with a negative x value which flips the image around the vertical.
    This all used to work perfectly fine until about a year ago when I got a later version of Java (can't remember which one, kind of gave up until now).
    The problem seems to occur when the rabbits face left. They can run that way for a while (time varies), but then suddenly their images start repeating themselves in a row, horizontally, and then the program freezes.
    So weird!
    Here is a exert from the loop that renders each rabbit:
    AffineTransform transform = new AffineTransform ();
    Rabbit rab = (Rabbit) i.next ();
    Image img;
    if (rab.getState () == Rabbit.DEAD){
         img = Globals.gravestone;
         rab.direction = Rabbit.LEFT;
    else
         img = rab.getImage ();
    double scale = 0.25 * (rab.getAge () < 3 ? (rab.getAge () + 1) : 4) * (0.5 + (double) rab.y / getHeight () * 0.5);
    int imgW = (int) (img.getWidth (null) * scale);
    int imgH = (int) (img.getHeight (null) * scale);
    if (rab.direction == Rabbit.RIGHT){
         transform.translate (rab.x + imgW / 2, rab.y - imgH / 2);
         transform.scale (-scale, scale);
    else{
         transform.translate (rab.x - imgW / 2, rab.y - imgH / 2);
         transform.scale (scale, scale);
    g.drawImage (img, transform, null);This is in a method render() within a JFrame, so getHeight() or getWidth() refer to that of the JFrame. The rabbits are also scaled depending on their age.
    Any help or explanations would be great. Thanks

    Here is the stack state when the command "new JFileChooser()" freezes my program:
    copyFirstPIDLEntry() : -1, sun.awt.shell.Win32ShellFolder2, Win32ShellFolder2.java
    createShellFolderFromRelativePIDL() : 57, sun.awt.shell.Win32ShellFolderManager2, Win32ShellFolderManager2.java
    getLinkLocation() : 622, sun.awt.shell.Win32ShellFolder2, Win32ShellFolder2.java
    isDirectory() : 471, sun.awt.shell.Win32ShellFolder2, Win32ShellFolder2.java
    get() : 200, sun.awt.shell.Win32ShellFolderManager2, Win32ShellFolderManager2.java
    get() : 221, sun.awt.shell.ShellFolder, ShellFolder.java
    updateUseShellFolder() : 500, com.sun.java.swing.plaf.windows.WindowsFileChooserUI, WindowsFileChooserUI.java
    installComponents() : 203, com.sun.java.swing.plaf.windows.WindowsFileChooserUI, WindowsFileChooserUI.java
    installUI() : 136, javax.swing.plaf.basic.BasicFileChooserUI, BasicFileChooserUI.java
    installUI() : 140, com.sun.java.swing.plaf.windows.WindowsFileChooserUI, WindowsFileChooserUI.java
    setUI() : 650, javax.swing.JComponent, JComponent.java
    updateUI() : 1755, javax.swing.JFileChooser, JFileChooser.java
    setup() : 366, javax.swing.JFileChooser, JFileChooser.java
    <init>() : 332, javax.swing.JFileChooser, JFileChooser.java
    <init>() : 285, javax.swing.JFileChooser, JFileChooser.java

  • Variable port in Socket class

    How does the variable "port" in the socket class point to the Network interface?

    How does the variable "port" in the socket class when
    given a value point to the specified port?I don't understand this at all, sorry.
    Also is there any way a port can be binded to and
    controlled when in use by an application like
    NetBios? ie opening or closing therby stopping the
    applications usage over a LAN.If a port number is already in use you can't do anything with it except try to connect to it.
    May I suggest Stevens TCP/IP Illustrated volume I.

  • Stupid question - method missing from Socket class

    I'm sure I am just missing something here. I am using getInputStream from Socket class successfully - now want to add setKeepAlive method - I am getting an error:
    Method setKeepAlive(boolean) not found in class java.net.Socket.
    client.setKeepAlive(true);
    client is defined as a Socket
    Socket client = origSocket.accept();
    What am I screwing up here?? I know the classpath is correct since I am and have been using getInputStream with this socket for months!!
    Thanks for any responses!
    Beth

    javac is the compiler, not the run-time. That would have nothing to do with what the classpath is at run-time, which would either be the system environment variable CLASSPATH, or the -cp command-line parameter to java, not javac.

  • Extending the Socket class...

    I need some help. The class below, SimpleSocket, extends the built-in
    Socket class and adds two methods to it. These methods are meant to
    make the class a bit more user-frienly but simplifying the reading-from
    and writing-to a Socket object. Here it is:
    bq. import java.net.*; \\ import java.io.*; \\ public class SimpleSocket extends Socket { \\ BufferedReader in; \\ PrintWriter out; \\ public void println(String line) throws IOException \\ { \\ if (out == null) { out = new PrintWriter(this.getOutputStream(), true); } \\ out.println(line); \\ } \\ public String readLine() throws IOException \\ { \\ if (in == null) { in = new BufferedReader( new InputStreamReader(this.getInputStream())); } \\ return in.readLine(); \\ } \\ }
    If I want to create a new SimpleSocket, it's easy - I can instantiate it like a normal Socket:
    bq. SimpleSocket socket = new SimpleSocket(host,port); // assume host & port have been defined
    Now, lets say I have a Socket object that I didn't created - for
    example, a Socket returned from the ServerSocket class - like this:
    bq. ServerSocket serverSocket = new ServerSocket(port); \\ Socket clientSocket = serverSocket.accept(); // returns the socket for communicating with a client
    Now that I have a regular Socket object, is there some what to
    "upgrade" it to a SimpleSocket? Something like this: (pseudocode):
    bq. clientSocket.setClass(SimpleSocket); // this is pseudocode
    Or, could I make a SimpleSocket constructor that accepted a Socket
    object as a parameter and then used it instead of creating a new
    object? Like this: (psuedocode):
    bq. public SimpleSocket(Socket S) \\ { \\ super = S; // this is pseudocode \\ }
    Any ideas would be greatly appreciated.
    Lindsay
    Edited by: lindsayvine on Sep 15, 2007 10:50 PM

    lindsayvine wrote:
    Ok, this makes sense and this is what I will probably do. However, there are three limitations to this method that I don't like:
    1. I would like to be able to pass the SimpleSocket object around as a normal Socket. I would like SimpleSocket to be castable to a Socket.Would you? What for? Are you sure? Would input and output streams not be better objects to pass around? You might well have the requirement you say you have, but I say it's an assumption to be challenged, at the very least
    2. I would like every method of the Socket object to be available - this would means that I have to rewrite out every method in SimpleSocket - instead of just saying "hey SimpleSocket, you should have every method Socket has"Yep. But using inheritance simply to avoid some typing is no reason to use inheritance. This is all providing that you need to have every method available. Remember, if any dependent code needs the underlying socket object, your interface can always expose it
    3. If I do write out every method, but then the Socket object gets new methods in future versions of Java, I will have to add the new ones.Likewise, in the case of such a change to java.net.Socket, your subclass has a very real chance of breaking. Again, consider if your code needs to exactly replicate everything a Socket does
    Can you think of any way around these problems?
    Sure. Re-think your design

  • Listen socket

    Hello,
    Can a listen socket be used for multiple webservers? Is it necessary to have a listen socket for individual virtual server?

    Multiple listen sockets can use the same IP address, but they must be listening on different ports.
    Multiple listen sockets can use the same port as long as the IP addresses are different.
    Please verify the doc section about this with what you want to make exactly ===>
    http://docs.sun.com/source/819-0130/agvirtual.html#wp1011171

Maybe you are looking for

  • Does not recognize printer

    Just got my G4 (9.2.2) back with new power supply. Decided to set it up on it's own with only a HP LaserJet 2100TN attached via Ethernet cable. Was previously setup on network with other computers via hub, router etc. Chooser does not see my HP print

  • Need help using music library on external hard drive

    Here is my scenario. I am hoping some one can help me as I have been having a heck of time trying to figure this out. I am what you would call newbie to Mac(I just purchased macBook) so bear with me). I have a iTunes library on an external hard drive

  • Printing/Saving to PDF not working

    When trying to save to pdf, I get this message: "Saving a PDF file when printing is not supported. Instead, choose File > Save." I have Adobe Acrobat Reader 9.1 So far I have been unable to save any documents to pdf. I am trying to print specific pag

  • How to concatenate fields in Search help exit

    Hi, My requirement is i have to create a search help for a field in cj20n transaction. when i press f4 on that field i should get a popup of 4 fields from custom table,when user selects any 1 row, first 3 field values should be concatenated and appea

  • How to send variable from vision builer to robot?

    hi all, i have a project with vision builder that generate variable of position.these varible i want to send it to a robot.it  is possible to send it directly from vision builder to the robot or i must to send varible ti labview firstly then to robot