Problem with appletContext.showDocument()

Hi All,
I'm facing a problem with opening new URL from applet.
The Java code
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import java.net.MalformedURLException;
public class OpenBrowser extends Applet
implements ActionListener {
public void init() {
     System.out.println("In init");
Button button = new Button("Bring up URL window");
button.addActionListener(this);
add(button);
System.out.println("init complete");
public void destroy() {
public void actionPerformed(ActionEvent event) {
String urlString = "http://java.sun.com/";
URL url = null;
try {
url = new URL("javascript:openScreen('"+urlString+"')");
} catch (MalformedURLException e) {
System.err.println("Malformed URL: " + urlString);
OpenBrowser.this.getAppletContext().showDocument(url);
HTML code
<HTML>
     <HEAD>
     <script>
     function openScreen(url)
          alert("Test Applet call Javascript");
          window.open(url);
     </SCRIPT>
     </HEAD>
     <BODY>
     <FORM NAME="form1">
          <APPLET codebase="." code="OpenBrowser.class"></APPLET>     
     </FORM>
     </BODY>
</HTML>
The whole idea is to open a new browser on click of the button on applet.
This is working with Windows 2000/JRE 1.5.0_02/IE6 SP1 Q837009 but not with Windows 2000/JRE 1.4.2/IE6 SP1 Q837009.
Awaiting your comments.

but not with Windows 2000/JRE 1.4.2/IE6 SNot working is too fague. Is it giving major minor version error than make sure you
compile the code to be used with 1.4 or 1.3 and higher.
javac -source 1.3 -target 1.3 .....
If the MSJVM is running your applet than stop using the applet tag and convert your html
page to use the object tag.
C:\Program Files\Java\jdk1.5.0\bin\HtmlConverter.exe
If anything else provide us with a full trace of the problem:
To turn the full trace on (windows) you can start the java console, to be found here:
C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
In the advanced tab you can fill in something for runtime parameters fill in this:
-Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
if you cannot start the java console check here:
C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
I think for linux this is somewhere in youruserdir/java (hidden directory)
add or change the following line:
javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
for 1.5:
deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
The trace is here:
C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
I think for linux this is somewhere in youruserdir/java (hidden directory)
Print out the full trace of the exception:
try{...}catch(Exception e){e.printStackTrace();}

Similar Messages

  • Problem with getAppletContext().showDocument (only sometime)

    My application do a lot of instruction like getAppletContext().showDocument(url, "_top").
    But sometime don't work (with same parameters)
    All my logs not show anything, don´t throw exception.
    what can i do?.
    Thanks.

    Windows xp sp3, iex 6.
    I can't reproduce it at other browser (i use third part software that is not compatible)
    and don't get reproduce at laboratory. I don't know what can i do it
    Thanks

  • What's wrong with my AppletContext.showDocument?

    ive been having a hard time figuring out my problem and i think its time to let this problem out to the world. im trying to call a certain html file to be shown on a certain frame of another html file, after a Java-made button is clicked.
    to clear things out, here's the code:
    <code>
    import java.applet.*;
    import java.net.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.AbstractButton;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    public class TestHomeButton extends Applet implements ActionListener {
         JButton homeButton;
         JPanel panel;     
         AppletContextAdapter fetchURL = new AppletContextAdapter();     
         public void init( ) {
              setLayout(new BorderLayout( ));
              setBackground(Color.white);
              homeButton = new JButton("Home");
              homeButton.setVerticalTextPosition(AbstractButton.CENTER);
         homeButton.setHorizontalTextPosition(AbstractButton.CENTER);
              homeButton.setToolTipText("History & Introduction");
              homeButton.setActionCommand("home");
              homeButton.addActionListener(this);
              add("Center", homeButton);
         public void start( ) {
              System.out.print("Applet starting.");
         public void stop( ) {
              System.out.print("Applet stopping.");
         public void destroy( ) {
              System.out.print("Destroy method called.");
         public void actionPerformed(ActionEvent e) {
    try
    // URL myUrl = new URL("simple.htm");
              if ("home".equals(e.getActionCommand( )))
                   fetchURL.showDocument(new URL("simple.htm"),"ButtonResults");
                   AppletContext.showDocument(new URL("simple.htm"),"ButtonResults");
    catch(Exception exept)
    </code>
    the code above is good for one button only. i have made a dozen of these but im just testing one button for now to get the solution right.. the other would be later...
    here's the (main) html file...
    <code>
    <html>
    <head> <title> SKI group </title> </head>
    <body background="bg_fade.gif">
    <center><table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
         <tr>
              <td colspan=11><br></td>
         </tr>
         <tr>
              <td colspan=11><br></td>
         </tr>
         <tr>
              <td width=25><br></td>
              <td width=50 align="center"><img src="house.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="puzzle.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="gears01.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="maze.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="peoplemove.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
         </tr>
         <tr>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestHomeButton.class" width=120 height=40> </applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestVariablesButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestOperatorsButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestFunctionsButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestCrewButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
         </tr>
         <tr>
              <td colspan=11><br></td>
         </tr>
         <tr>
              <td colspan=12>
                   <iframe name="ButtonResults" src="welcome.htm"
                        width="700" height="500"
                        scroll="0" frameborder="0">
                   </iframe>
              </td>
         </tr>
    </table></center>
    </body>
    </html>
    </code>
    so, once homeButton is clicked it calls on another html file to be shown inside the iframe... unfortunately, it just didnt work :-(
    i am hoping you guys here could help me out and enlighten me...
    thanks, in advance
    Bar

    Try:public void actionPerformed(ActionEvent e) {
        try {
            if ("home".equals(e.getActionCommand()))
                getAppletContext().showDocument(new URL("simple.htm"), "ButtonResults");
        ...Next time please paste your code between &#91;code&#93; &#91;/code&#93; tags with the help of the code button just above the message box.
    It makes the code readable.
    Regards

  • Problem with showDocument

    I am having an applet that i lauch through WebStart. After doing some operations the applet launches a webpage. This i am achieving with the help of appletContext.showDocument((url, string) method, where the string can be "_self" or " _parent" or "_blank" to indicate whether the web page has to be launched by in a new window or in the parent window etc. But whatever option i give as the string parameter the web page gets launched in a "new window". I want to launch the webpage in the window that launched the applet. How can i do that? When I try using showDocument when the applet is embedded in the webpage it works fine! Please help me with this problem!

    Unfortunately, there is no "window that launched the applet". A Java Web Start application or applet is launched (sometimes by a browser, sometimes not) as a seperate process, and has no connection to the browser when it is running. Most of the AppletContext showDocument args therefore have no meaning. The applet is not actually running in the browser, but in the download window, so any showDocuement requires launching a new browser. (which may use an existing browsers instance, depending on the browser and version)
    /Dietz

  • AppletContext.showDocument() no longer working correctly

    I am using appletContext.showDocument(), and it is not working now, I have IE 5.5 sp1, windows 2000 sp2. It still seems to work for others. Here is the code:
    String location =
    "http://mysite/controlcgi.dll?cmd=Restart";
    URL url = new URL(location);
    getAppletContext().showDocument(url);
    When the url gets to the webserver, it appears the params are encoded - "cmd+ADO-Restart". I tried using the URLEncoder to encode the params first, but that did not work. Anyone with an idea?
    Thanks
    Kelley

    I found the problem, I did not have the content-type defined in the web page where the applet was located. I added <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    and it started working fine. My best guess is that before IE 5.5 sp1 IE would default to this content type. Thanks for the help.

  • Any problem with Runtime.exec()

    I am required to launch a local exe from an applet. At present I am using AppletContext.showDocument().The problem with this is that in netscape a box is popped up forcing the user to save that exe file. The requirwment is to run it directly without any message being asked.
    A workaround is to use Runtime.exec(), it works, however I have heard that it is not platform independent.
    (1) Is there a better solution than Runtime.exec() ?
    (2) If not could you give me some info on Runtime.exec() and the problems associated with it ?
    (3) Is there a way to use AppletContext.showDocument() without the message being asked ?
    Shikari.

    First of all, Java is platform independent language, and has many security restriction in it's applets.
    so from an applet you can't excute a program using "Runtime.getRuntime().exec()".
    coz. there is security restriction on that.
    for the "AppletContext.showDocument()" this methid is for displaying the specified document on the client browser, so it can't excute a client program.
    if u need to use Runtime.getRuntime().exec() you have to get the client agreement for that.
    see the applet security restriction for more info.

  • Problem with EXP 10.1.0.3.0

    I have problem with EXP in Oracle (linux Fedora 3). I used command as oracle:
    exp userid=user/pass@server file=/tmp/dmp.dmp
    and I got message.
    Export: Release 10.1.0.3.0 - Production on Fri Mar 4 10:13:40 2005
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.0.0 - Production
    EXP-00056: ORACLE error 942 encountered
    ORA-00942: table or view does not exist
    EXP-00000: Export terminated unsuccessfully
    Witch tables or views does not exist ? Does export from oracle 10g clinet work with 8.1.7 database ?
    I used expcat.sql from rdbms.

    From 10.1.0 to 8.1.7 => Use the EXPORT 8.1.7 to export the data from the
    10.1.0 database and IMPORT 8.1.7 to import the
    data into the 8.1.7 database.more info on the imp/exp matrix :
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=132904.1

  • Problem using AppletContext

    hi
    i'm trying to open a web page thru the applet.i'm using the
    appletcontexts showDocument(),the program compiles but
    shows nothing. here is the code for the applet
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.lang.*;
    import javax.swing.*;
    /*<applet code= "try1" width = 200 height = 300>
    </applet>*/
    public class try1 extends Applet implements ActionListener
    JButton cb1;
    URL url;
    AppletContext appletContext;
    public     void init()
         cb1 = new JButton("Display");
         cb1.addActionListener(this);
         add(cb1);
    public void actionPerformed(ActionEvent qe)
    {     String action = qe.getActionCommand();
         this.appletContext = appletContext;
         if (action.equals("Display"))
              try {
              url = new URL("http://www.rediff.com");
              appletContext.showDocument(url);
              } catch (java.net.MalformedURLException e) {System.out.println(e);}
    what is the problem???
    thanx in advance
    Ashish

    Actually when i use appletviewer it doesnt work but
    works otherwise.

  • Important Problem with sysaux01.dbf

    After a problem with my scsi driver i couldn't open database.
    When i try to open oracle gives me a message as this;
    ERROR at line 1:
    ORA-01113: file 3 needs media recovery
    ORA-01110: data file 3: 'D:\ORACLE\ORADATA\NETSIS07\SYSAUX01.DBF'
    Help me !!!

    You can try the following:
    startup mount
    ORACLE instance started.
    Total System Global Area 522788800 bytes
    Fixed Size 454592 bytes
    Variable Size 301989888 bytes
    Database Buffers 209715200 bytes
    Redo Buffers 10629120 bytes
    Database mounted.
    SQL> recover database;
    Media recovery complete.
    SQL> alter database open;
    Database altered.
    SQL>shutdown immediate;
    Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=28814.1

  • Intermittent Problem with Business Event.

    Hi,
    I have a problem with a BES Event. My suspicions are that the event is intermittently nor firing. It's custom code subscribed to '*.apps.ar.hz.PersonProfileExtAttr.Update' (an EBS Person Profile Extensible Attribute Update).
    In the first lines of the custom code an audit is written to a table. For some one the updates to the Extensible Attribute no audit is written.
    The table HZ_PARAM_TAB is cleared for the item
    Q: Is there a way to prove that the BES Event did/did not fire?
    Thanks in Advance,
    Kieran.

    Kieran,
    Never experienced any performance issues when setting this profile option. However, you may review the following documents.
    Note: 280849.1 - How To Purge/Delete The Information From HZ_PARAM_TAB Table ?
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=280849.1
    Note: 187275.1 - TCA API Callouts/Workflow 2.6 Business Event System: Performance Issue
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=187275.1
    Note: 171703.1 - 11.5.x: Implementing Oracle Workflow Directory Service Synchronization
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=171703.1
    Regards,
    Hussein

  • Problems with Netscape...

    Hi friends,
    (Apps: 11.5.7 DB: 8.1.7)
    In selfservice I have a link to an image stored in database ... when I do click with Internet explorer, it shows the image withput problem but.. if I try to do it with Netscape (6.2) It appears a page with ascii chars... Any idea of this?
    It doesn't occurs with Firefox...(it runs ok)
    Thanks,
    Jose.

    Jose, Netscape 7.2 is certified with:
    - Oracle Applications patch 9 (11.5.9) or later
    - Oracle Developer 6i patchset 15 (6.0.8.24.x) or later
    - Oracle Applications Framework 11i.FWK.H or later
    - Windows XP/2000
    - JInitiator 1.3.1.x
    NOTE: Netscape 7.2 is no longer supported by the vendor. Oracle will continue to offer support for this browser with E-Business Suite on a 'Best Effort' basis only. Consequently, where issues are due to problems with the browser, we may, where necessary, require customers to upgrade or change their browser to resolve the issue.
    No future certification of the Netscape browser is currently planned by Oracle. Firefox browser by Mozilla.org is certified for E-Business Suite.
    Note: 285218.1 - Recommended Browsers for Oracle Applications 11i
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=285218.1

  • Strange Problems with XDK v10 Beta Version

    Hello together,
    I encounter two strange problems with the new 10.1.0.0.0 Beta release of XDK. I already posted them in the Beta Release Testing Forum, but got no replies, so I decided to start another try here. Maybe anyone can help me...
    I upgraded a fine-working XSQL web application from XDK 9.2.0.4 to the new 10.1.0.0.0 Beta release of XDK. Since then, two bugs came up, which are reproducible by will:
    1.)
    When processing XSQL insert-requests, the error given below is thrown. I already found an entry in the bug database that says that exactly this error should have been fixed since 9.2.0.3 (see http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=230695.1), but no it seems to be there again.
    This is the stack trace:
    XSQL-017: Unexpected Error Occurred
    java.lang.NoClassDefFoundError: oracle/sql/OPAQUE
    at oracle.xml.xsql.actions.XSQLInsertRequestHandler.handleAction(XSQLInsertRequestHandler.java:118)
    at oracle.xml.xsql.XSQLDocHandler.getDocument(XSQLDocHandler.java:158)
    at oracle.xml.xsql.XSQLPageProcessor.process(XSQLPageProcessor.java:171)
    at oracle.xml.xsql.XSQLServlet.doGet(XSQLServlet.java:61)
    at oracle.xml.xsql.XSQLServlet.doPost(XSQLServlet.java:82)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    2.)
    When I deploy and start the application now, I always get the following error only once(!) after deployment when I call the application for the first time:
    XSQL-017: Unexpected Error Occurred
    java.lang.NullPointerException
    at weblogic.jdbc.oci.Statement.executeQuery(Statement.java:865)
    at oracle.xml.xsql.actions.XSQLQueryHandler.handleAction(XSQLQueryHandler.java:161)
    at oracle.xml.xsql.XSQLDocHandler.getDocument(XSQLDocHandler.java:158)
    at oracle.xml.xsql.XSQLPageProcessor.process(XSQLPageProcessor.java:171)
    at oracle.xml.xsql.XSQLServlet.doGet(XSQLServlet.java:61)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    When I reload the same page, it works. However, this is not really a good state for productive use.
    Any ideas? After days of research, I'd be very glad for any help.
    Thanks alot,
    Eckhard

    Once again me:
    I guess I should partially revoke for the second topic: The error described above under 2.) seems to be rather a Weblogic versioning problem than a XDK bug, as it only occurs when deploying the application to WebLogic 7.0 (instead of 6.1, which was used before). Maybe I should search the BEA docs for an answer.
    However, the first bug is still a problem to me...

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    Thanks,
    B.D.
    Code:
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
                       GetState();
            objMainProcess.setDaemon( true );
            objMainProcess.start();
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
                              SetState();
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                try{
                    objMainProcess.notify();
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    SendMessage();
                    bChanged = false;
                    return true;
                try {
                    objMainProcess.wait();
                }catch( InterruptedException e ) {}
                return false;
        }

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.
    Thanks,
    B.D.

  • Problem with threads running javaw

    Hi,
    Having a problem with multi thread programming using client server sockets. The program works find when starting the the application in a console using java muti.java , but when using javaw multi.java the program doesnt die and have to kill it in the task manager. The program doesnt display any of my gui error messages either when the server disconnect the client. all works find in a console. any advice on this as I havent been able to understand why this is happening? any comment would be appreciated.
    troy.

    troy,
    Try and post a minimum code sample of your app which
    does not work.
    When using javaw, make sure you redirect the standard
    error and standard output streams to file.
    Graeme.Hi Graeme,
    I dont understand what you mean by redirection to file? some of my code below.
    The code works fine under a console, code is supposed to exit when the client (the other server )disconnects. the problem is that but the clientworker side of the code still works. which under console it doesnt.
    public class Server{
    ServerSocket aServerSocket;
    Socket dianosticsSocket;
    Socket nPortExpress;
    ClientListener aClientListener;
    LinkedList queue = new LinkedList();
    int port = 0;
    int clientPort = 0;
    String clientName = null;
    boolean serverAlive = true;
    * Server constructor generates a server
    * Socket and then starts a client threads.
    * @param aPort      socket port of local machine.
    public Server(int aPort, String aClientName, int aClientPort){
    port = aPort;
    clientName = aClientName;
    clientPort = aClientPort;
    try{
    // create a new thread
    aServerSocket = new ServerSocket(port) ;
    // connect to the nPortExpress
    aClientListener = new ClientListener(InetAddress.getByName(clientName), clientPort, queue,this);
    // aClientListener.setDaemon(true);
    aClientListener.start();
    // start a dianostic port
    DiagnosticsServer aDiagnosticsServer = new DiagnosticsServer(port,queue,aClientListener);
    // System.out.println("Server is running on port " + port + "...");
    // System.out.println("Connect to nPort");
    catch(Exception e)
    // System.out.println("ERROR: Server port " + port + " not available");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Server port " + port + " not available", JOptionPane.ERROR_MESSAGE);
    serverAlive = false;
    System.exit(1);
    while(serverAlive&&aClientListener.hostSocket.isConnected()){
    try{
    // connect the client
    Socket aClient = aServerSocket.accept();
    //System.out.println("open client connection");
    //System.out.println("client local: "+ aClient.getLocalAddress().toString());
    // System.out.println("client localport: "+ aClient.getLocalPort());
    // System.out.println("client : "+ aClient.getInetAddress().toString());
    // System.out.println("client port: "+ aClient.getLocalPort());
    // make a new client thread
    ClientWorker clientThread = new ClientWorker(aClient, queue, aClientListener, false);
    // start thread
    clientThread.start();
    catch(Exception e)
    //System.out.println("ERROR: Client connection failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client connection failure", JOptionPane.ERROR_MESSAGE);
    }// end while
    } // end constructor Server
    void serverExit(){
         JOptionPane.showMessageDialog(null, "Server ","ERROR: nPort Failure", JOptionPane.ERROR_MESSAGE);
         System.exit(1);
    }// end class Server
    *** connect to another server
    public class ClientListener extends Thread{
    InetAddress hostName;
    int hostPort;
    Socket hostSocket;
    BufferedReader in;
    PrintWriter out;
    boolean loggedIn;
    LinkedList queue;      // reference to Server queue
    Server serverRef; // reference to main server
    * ClientListener connects to the host server.
    * @param aHostName is the name of the host eg server name or IP address.
    * @param aHostPort is a port number of the host.
    * @param aLoginName is the users login name.
    public ClientListener(InetAddress aHostName, int aHostPort,LinkedList aQueue,Server aServer)      // reference to Server queue)
    hostName = aHostName;
    hostPort = aHostPort;
    queue = aQueue;
    serverRef = aServer;      
    // connect to the server
    try{
    hostSocket = new Socket(hostName, hostPort);
    catch(IOException e){
    //System.out.println("ERROR: Connection Host Failed");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort Failed", JOptionPane.ERROR_MESSAGE);     
    System.exit(0);
    } // end constructor ClientListener
    ** multi client connection server
    ClientWorker(Socket aSocket,LinkedList aQueue, ClientListener aClientListener, boolean diagnostics){
    queue = aQueue;
    addToQueue(this);
    client = aSocket;
    clientRef = aClientListener;
    aDiagnostic = diagnostics;
    } // end constructor ClientWorker
    * run method is the main loop of the server program
    * in change of handle new client connection as well
    * as handle all messages and errors.
    public void run(){
    boolean alive = true;
    String aSubString = "";
    in = null;
    out = null;
    loginName = "";
    loggedIn = false;
    while (alive && client.isConnected()&& clientRef.hostSocket.isConnected()){
    try{
    in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
    if(aDiagnostic){
    out.println("WELCOME to diagnostics");
    broadCastDia("Connect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    out.println("WELCOME to Troy's Server");
    broadCastDia("Connect : client "+client.getInetAddress().toString());
         out.flush();
    String line;
    while(((line = in.readLine())!= null)){
    StringTokenizer aStringToken = new StringTokenizer(line, " ");
    if(!aDiagnostic){
    broadCastDia(line);
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    else{
    if(line.equals("GETIPS"))
    getIPs();
    else{
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    } // end while
    catch(Exception e){
    // System.out.println("ERROR:Client Connection reset");
                             JOptionPane.showMessageDialog(null, (e.toString()),"ERROR:Client Connection reset", JOptionPane.ERROR_MESSAGE);     
    try{
    if(aDiagnostic){
    broadCastDia("Disconnect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    broadCastDia("Disconnect : client "+client.getInetAddress().toString());
         out.flush();
    // close the buffers and connection;
    in.close();
    out.close();
    client.close();
    // System.out.println("out");
    // remove from list
    removeThreadQueue(this);
    alive = false;
    catch(Exception e){
    // System.out.println("ERROR: Client Connection reset failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client Connection reset failure", JOptionPane.ERROR_MESSAGE);     
    }// end while
    } // end method run
    * method run - Generates io stream for communicating with the server and
    * starts the client gui. Run also parses the input commands from the server.
    public void run(){
    boolean alive = true;
    try{
    // begin to life the gui
    // aGuiClient = new ClientGui(hostName.getHostName(), hostPort, loginName, this);
    // aGuiClient.show();
    in = new BufferedReader(new InputStreamReader(hostSocket.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(hostSocket.getOutputStream()));
    while (alive && hostSocket.isConnected()){
    String line;
    while(((line = in.readLine())!= null)){
    System.out.println(line);
    broadCast(line);
    } // end while
    } // end while
    catch(Exception e){
    //     System.out.println("ERRORa Connection to host reset");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort reset", JOptionPane.ERROR_MESSAGE);
    try{
    hostSocket.close();
         }catch(Exception a){
         JOptionPane.showMessageDialog(null, (a.toString()),"ERROR: Exception", JOptionPane.ERROR_MESSAGE);
    alive = false;
    System.exit(1);
    } // end method run

Maybe you are looking for

  • SAP NetWeaver 7.01 ABAP Trial Version - You can only work in client 001

    Hi BI Experts, I have installed SAP NetWeaver 7.01 ABAP Trial Version and I could successfully login into the system. When I run RSA1 Tcode I am getting error message You can only work in client 001. Can some please advice. I appreciate all your inpu

  • Getting new ipod--can I get my songs off of iTunes?

    My old mini has died and I think I am going to get a nano to replace it. My question is will itunes let me get all my songs to put them on my new nano? They must have some way of doing this since I can't be the only one to ever get a new device and t

  • Adobe Reader 9.0 Installation problem

    When I try to install Reader 9.0, the progress bar gets to 99.9% done and then a copy utility window opens from my printer. If I press the copy button, the printer attempts to copy something and spits out a blank sheet and then nothing happens. If I

  • 7.0.2 release date?

    I want very badly to get a new 2 gen nano but after the MASSIVE problems reported here and at ilounge, there is NO way i will have that crap ware on my computer. Of course this means no new nano, as it will not work with the latest stable version of

  • How do I enable parent paths in Visual Studio 2013?

    I am converting a classic ASP site to a Visual Studio 2013 MVC. When I run the ASP code inside of the Visual Studio 2013 debugger I get the following error message. How can I enable parent paths in 2013?  Active Server Pages error 'ASP 0131' Disallow