Swing Program Slow on Some Computers Second Instance Always Fast

I am having a unusual and frustrating problem. I have a java swing application compiled and run with 1.5.06.
On some computers the program runs very slowly and takes a long time to paint to the screen. If however, you run a second instance of the program the second instance runs very fast. If you close the first instance the second instance remains fast.
Running the java console first will also make my program fast.
On other PC's with the identical hardware it runs fine the first time. All the computers involved run windows 2000.
Please help with this weird problem. Thanks.

It seems that you need to fine tune ur JVM based you requirement.
Try setting the max heap size.
Also, You can tyr -XX jvm option. But the decision purely depends on you applications behaviour.
Thanks
Jobinesh

Similar Messages

  • Javax.swing.SwingUtilities.invokeLater make my program slow

    i am writing a program in which i am implementing documentlistener
    to communicating between two frames
    if i write my code with javax.swing.SwingUtilities.invokeLater it makes my program slow
    and if i write without this thread safe quality then this is fast but giving me runtime exception
    what i do to make my program better
    kindly suggest
    public void insertUpdate(DocumentEvent e) {
                updateLog(e, "inserted into");
            public void removeUpdate(DocumentEvent e) {
                updateLog(e, "removed from");
            public void changedUpdate(DocumentEvent e) {
                //Plain text components don't fire these events.
            public void updateLog(DocumentEvent e, String action) {
                Document doc = (Document)e.getDocument();
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
    tf4.setText(lbl.getText());
    }

    If your program is becoming too slow or unresponsive, it means that the operation "tf4.setText(lbl.getText());" is taking too long to execute and is therefore blocking the Swing-thread.
    There is little you can do to make that operation faster, but perhaps you can change how or how often you update the frames.
    Setting the whole text via setText() everytime a change happens seems very wasteful. Imagine you have a text with a million characters, and every time the user adds or changes just one character, you are getting and seting over one million characters. That is not the right approach.
    I'm not familiar with text-operations or class DocumentEvent, but I guess that there should be some kind of delta in DocumentEvent containing only the changes that were made. You could apply only these changes on tf4 instead of setting the whole text. Finding out how to do this would be the best solution. This will also make your program more scalable, as with setText() the performance of your application will continuously decrease as the text length increases.
    Usually when working with documents you have a "viewer" and a "model". If your viewer was a JTextBox and your model was, say a StringBuilder, you could make quick changes to the contents of JTextBox using the StringBuilder.append() or delete() methods without having to modify the whole text. You need to find out how this is done with whatever UI system you're using.
    If you can't find out how to do the above, a workaround would be to reduce how often you call "updateLog()". For example, is it truly necessary to call "updateLog" every time a new update happens? Perhaps it would be better to use a timer and only call "updateLog()" every few seconds.
    But as I said, this should only be a temporary workaround. You really should find out how to perform more efficient updates without using setText(). I recommend you search for tutorials and guides on how to work with text and documents on the internet.

  • Slow Searches on XServe...from SOME computers

    Having a weird issue where I have some computers logging into our XServe that are getting really slow search results. My Macbook gets lightning quick search results, and one of the iMacs we have gets very fast search results as well. However, we have systems that just search and search. Whereas my laptop finds things more or less instantly, our Mac towers (which range from 2x2.66GHz Dual Cores with 5GB of RAM to a Dual 2GHz Power PC G5) take forever on searches.
    It's not a network issue, as they can search each others drives very rapidly. And it doesn't appear to be a system software issue, as while I am running Leopard (as is the server), the iMac is running 10.4.11, as are the Mac towers.
    Any help would be VERY appreciated - this is incredibly frustrating!!!
    R~

    Hi Randy Baer1-
    Might be a bad idea to discount a network problem so quickly. Speaking of which, is this a wired, wireless or mixed network?
    Are you sure that the Macs in question are connected at the speed that you think they are? Do all of the machines take the same physical route to the servers? Are the slow G5s connected to the same physical switch or router? If they are wired have you tried swapping ports on the switch or router to which the Macs are wired?
    Luck-
    -DP

  • I have i4s .when i installed i0s 7.0.1 its speed became slow. when i wanted to hear my recorded program, there was no sound. secondly side buttons + and -

    i have i4s .when i installed i0s 7.0.1 its speed became slow. when i wanted to hear my recorded program, there was no sound. secondly side buttons + and - are not working properly. thirdly face time is not present in settings
    kindly help

    Device Manager which is in Control Panels
    I strongly recommend AIDA64 to show everything, temps, fans, chips, drivers and versions
    http://www.aida64.com/ Windows has better tools to show you every service and knick and cranny
    https://discussions.apple.com/thread/2769294
    http://realitypod.com/category/hacks-and-cracks/mac-hacks-and-cracks/
    MacBook definitely uses Cirrus - probably iMac

  • Keyboard-lock of swing program on Linux box

    We are developing swing program on Linux, and we often meet keyboard-lock issues.
    I try to simplify some of them to small programs, and still meet keyboard-lock.
    Here I post two programs to show the error:
    //---first ----------------------------------------------
    package test;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class KeyLock extends JFrame {
      JPanel contentPanel = new JPanel();
      JPanel wizardToolPan = new JPanel();
      JButton btnBack = new JButton("Back");
      JButton btnNext = new JButton("Next");
      JButton btnAbout = new JButton("About");
      public static final String aboutMsg =
              "<html>  This program will help to find keyboard lock problems, two way to reproduce:<br><br>" +
              "1 - press Alt+N to navigate next, and don't release keys untill there are no more next page, <br>" +
              "then try Alt+B to navigate back and also don't release keys untill page 0,<br>" +
              "repeat Alt+N and Alt+B again and again, keyboard will be locked during navigating. <br><br>" +
              "2 - press Alt+A in main window, it will popup an about dialog,<br>" +
              "then press down space key and don't release, <br>" +
              "the about dialog will be closed and opened again and again,<br>" +
              "keyboard will be locked sooner or later." +
              "</html>";
      public KeyLock() {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setTitle("Keyboard lock test");
        getContentPane().setLayout(new BorderLayout());
        btnBack.setMnemonic('B');
        btnBack.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            KeyLock.this.goBack(e);
        btnNext.setMnemonic('N');
        btnNext.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            KeyLock.this.goNext(e);
        btnAbout.setMnemonic('A');
        btnAbout.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(KeyLock.this, aboutMsg, "About", JOptionPane.INFORMATION_MESSAGE);
        contentPanel.setLayout(new BorderLayout());
        contentPanel.setPreferredSize(new Dimension(400, 250));
        contentPanel.setMinimumSize(new Dimension(400, 250));
        wizardToolPan.setLayout(new FlowLayout());
        wizardToolPan.add(btnBack);
        wizardToolPan.add(btnNext);
        wizardToolPan.add(btnAbout);
        this.getContentPane().add(contentPanel, java.awt.BorderLayout.CENTER);
        this.getContentPane().add(wizardToolPan, java.awt.BorderLayout.SOUTH);
        this.setSize(400, 300);
        this.createContentPanels();
        this.showCurrent();
      private Vector<JPanel> slides = new Vector<JPanel>();
      private int current = 0;
      private void createContentPanels() {
        for (int j = 0; j < 20; ++j) {
          JPanel p = new JPanel(new FlowLayout());
          p.add(new JLabel("Page: " + j));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JLabel("Input something in password box:"));
          p.add(new JPasswordField(20));
          p.add(new JCheckBox("Try click here, focus will be here."));
          p.add(new JRadioButton("Try click here, focus will be here."));
          slides.add(p);
      public void showCurrent() {
        if (current < 0 || current >= slides.size())
          return;
        JPanel p = slides.get(current);
        this.contentPanel.add(p, java.awt.BorderLayout.CENTER);
        this.pack();
        Component[] comps = p.getComponents();
        if (comps.length > 0) {
          comps[0].requestFocus(); // try delete this line
        this.repaint();
      public void goNext(ActionEvent e) {
        if (current + 1 >= slides.size())
          return;
        this.contentPanel.remove(slides.get(current));
        current++;
        sleep(100);
        this.showCurrent();
      public void goBack(ActionEvent e) {
        if (current <= 0)
          return;
        this.contentPanel.remove(slides.get(current));
        current--;
        sleep(100);
        this.showCurrent();
      public static void sleep(int millis) {
        try {
          Thread.sleep(millis);
        } catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        KeyLock wizard = new KeyLock();
        wizard.setVisible(true);
    }The first program will lead to keyboard-lock in RHEL 4 and red flag 5, both J2SE 5 and 6.
    //---second -----------------------------------------
    package test;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class KeyFocusLost extends JFrame {
      private JButton btnPopup = new JButton();
      private JTextField jTextField1 = new JTextField();
      private JPasswordField jPasswordField1 = new JPasswordField();
      private JPanel jPanel1 = new JPanel();
      private JScrollPane jScrollPane3 = new JScrollPane();
      private JTree jTree1 = new JTree();
      private JButton btnAbout = new JButton("About");
      public static final String aboutMsg =
              "<html>  This program is used to find keyboard focus lost problem.<br>" +
              "Click 'popup' button in main window, or select any node in the tree and press F6,<br>" +
              "a dialog popup, and click ok button in the dialog,<br>" +
              "keyboard focus will lost in main window." +
              "</html>";
      public KeyFocusLost() {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setTitle("Keyboard focus test");
        getContentPane().setLayout(null);
        btnPopup.setBounds(new Rectangle(33, 482, 200, 35));
        btnPopup.setMnemonic('P');
        btnPopup.setText("Popup and lost focus");
        btnPopup.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            PopupDialog dlg = new PopupDialog(KeyFocusLost.this);
            dlg.setVisible(true);
        btnAbout.setBounds(new Rectangle(250, 482, 100, 35));
        btnAbout.setMnemonic('A');
        btnAbout.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(KeyFocusLost.this, aboutMsg, "About", JOptionPane.INFORMATION_MESSAGE);
        jTextField1.setText("Try input here, and try input in password box below");
        jTextField1.setBounds(new Rectangle(14, 44, 319, 29));
        jPasswordField1.setBounds(new Rectangle(14, 96, 319, 29));
        jPanel1.setBounds(new Rectangle(14, 158, 287, 291));
        jPanel1.setLayout(new BorderLayout());
        jPanel1.add(new JLabel("Select any node in the tree and press F6."), java.awt.BorderLayout.NORTH);
        jPanel1.add(jScrollPane3, java.awt.BorderLayout.CENTER);
        jScrollPane3.getViewport().add(jTree1);
        Object actionKey = "popup";
        jTree1.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), actionKey);
        jTree1.getActionMap().put(actionKey, new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            PopupDialog dlg = new PopupDialog(KeyFocusLost.this);
            dlg.setVisible(true);
        this.getContentPane().add(jTextField1);
        this.getContentPane().add(jPasswordField1);
        this.getContentPane().add(jPanel1);
        this.getContentPane().add(btnPopup);
        this.getContentPane().add(btnAbout);
      public static void main(String[] args) {
        KeyFocusLost keytest = new KeyFocusLost();
        keytest.setSize(400, 600);
        keytest.setVisible(true);
      static class PopupDialog extends JDialog {
        private JButton btnOk = new JButton();
        public PopupDialog(Frame owner) {
          super(owner, "popup dialog", true);
          setDefaultCloseOperation(DISPOSE_ON_CLOSE);
          this.getContentPane().setLayout(null);
          btnOk.setBounds(new Rectangle(100, 100, 200, 25));
          btnOk.setMnemonic('O');
          btnOk.setText("OK, then focus lost");
          btnOk.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              PopupDialog.this.getOwner().toFront();
              try {
                Thread.sleep(100); // try delete this line !!!
              } catch (Exception ex) {
                ex.printStackTrace();
              PopupDialog.this.dispose();
          this.getContentPane().add(btnOk);
          this.getRootPane().setDefaultButton(btnOk);
          this.setSize(400, 300);
    }The second program will lead to keyboard-focus-lost in RHEL 3/4 and red flag 4/5, J2SE 5, not in J2SE 6.
    And I also tried java demo program "SwingSet2" in red flag 5, met keyboard-lock too.
    I guess it should be some kind of incompatibleness of J2SE with some Linux platform. Isn't it?
    Please help, thanks.

    Hi.
    I have same problems on Ubuntu with Java 6 (all versions). I would like to use NetBeans or IntelliJ IDEA but it is not possible due to keyboard locks.
    I posted this bug
    https://bugs.launchpad.net/ubuntu/+bug/174281
    before I found some info about it:
    http://forums.java.net/jive/thread.jspa?messageID=189281
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6506617
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6568693
    I don't know from which part this bug comes, but I wonder why it isn't fixed yet. Does anybody else use NetBeans or IntelliJ IDEA on linux with Java 6 ?
    (I cannot insert link :\ )

  • At odd times I will get a second instance of Firefox startup. I have run avast av, spybot, malwarebytes, both in normal and safe mode and nothing has been found, any ideas?

    at odd times I will get a second instance of Firefox startup. I have run avast av, spybot, malwarebytes, both in normal and safe mode and nothing has been found, any ideas?

    That second one sounds like malware.
    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    *http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • HELP! Flash header cutting off, but only on some computers

    http://www.omsstrategicadvisors.com/
    Our site has been up for approx 9 months and there's been no problem. Now all of a sudden, on SOME computers that were perfectly fine, the flash header is getting cut off.   Well, I guess magnified is a better description...
      I have not been able to recreate the issue on my screen. All the "guilty" computers have ie8, while I am stubbornly still on ie7, which is why I was thinking ie8 might be the culprit. However my bus. partner has multiple systems running and it looks perfectly fine on ie8, chrome, and firefox. Even problem computers have moments of clarity, for instance it happened on my husband’s pc then I refreshed the images and it corrected itself.  Then at the customer site, I opened the url on one of the “offending” computers, it was cut off again until I logged in…then it corrected itself immediately.  But when I tried that on the computer I am testing today, it did not work.  Then I was checking the Compatibility View Settings within ie8, I unchecked the box regarding Intranets, and it worked.  Thinking I’d found something, I went back in and re-checked it, and the problem was back, ok….now I really thought I was getting somewhere.  But when I went in again and un-check the box….nothing…still wrong.  Over the past 2 days, I’ve updated their Flash Players,  made sure all the images were the same size, deleted and re-uploaded the pix and xml files, contacted the skin author, anything I could think of.  The author also checked all the CSS and site setting, everything looked in order.  Also tried using the Compatibility View feature, setting that site to only be shown in IE 7, it did not work, which makes me think maybe it’s not the browser. I just attempted to back the computer down to an earlier version of Flash Player (9 as opposed to 10.1).  Also did not work.
    Of course, the client is freaking thinking about the big client that is due to check them out this week.  I’ve been searching every support/community forum looking for someone else with this problem…if you have any answers or know of any better places for me to look, please let me know.
    Any help is truly appreciated.

    Hi, I just checked your site and it looked good to me, headers changing nicely and no glitches. The header and the body of the site filled my 19" monitor which I use with my work computer. XP/SP3/IE6 with Flash Player 10.1.82.76. Yes that is IE6:-) In your screen shot, there are extra wide margins(empty space) on the left and the right side. And it blocks the text. That did not appear when I went to the site. However there was extra space on the left and right sides both, but not so much that the entire text could not be seen. On www.bing.com the site comes much closer to the scroll bar. 
    Your Tech experience is way above my head as I am not into what you do. However I do pretty well at researching so I'll see what I can find that might point you into the right direction.
    My only observation is that this happened "all of a sudden". Some kind of change must have happened. Could a user have made a change on the computers that are having this issue? Some Anti-Virus update?
    I don't really think it is Flash Player related and for this reason: It is not consistent. Most all of the time some program with certain add ons into the browser, especially Anti-Virus add ons are what affects the Flash Player ActiveX Control that is in the browser. Flash Player is a browser plugin so any add on in the browser is a negative or a positive.
    You may want to use the Adobe SEARCH field or the SEARCH at the top for Forums. You would know what key words would work best. The Forum SEARCH may be better to use since it covers all Adobe Product Forums.
    Thanks,
    eidnolb
    Message was edited by: eidnolb   correct spelling

  • Application lags, until second Instance is started - AND no lagging on another machine...

    Hey, it's me again:
    The last days I started to get along with LabWindows quite well, and my program grew very fast, but today I found a probleme, I do not really know how to handle.
    When I compile my program (both in "debug" and "release"-mode), and start it, it lags quite a lot, but the another version, I still had from friday and did NOT lag that day, started to lag too. So there must be any problem with maybe the configuration or whatever.
    But the weirdest thing:
    When I first start one Version (does not matter which one), and than afterwards start another Instance of it, or a complete other Version (maybe one Version of Friday, and on I just compiled), the second Application (which lags when being started alone), does NOT lag at all.
    In addition to that, all Versions do NOT lag, when I start them on a little netbook, where they're supposed to be used anyway.
    Sumarizing:
    1 Instance --> lagging
    2 Instances --> first lags, second doesn't
    This whole thing is very frustrating
    I hope, some of you may know what to do!
    Greetings from Lübeck
    Mathias

    MacMatze:
    Glad you found the problem.  You don't need to be embarrassed by it, but you should learn from it.  It sounds like you need to do some error handling, and should probably do some status reporting.  Here are a couple of suggestions.
    1. To troubleshoot a "lagging" problem, you could single-step through your code to see which statement takes longer than you expect.
    2. If the problem was that a power supply was unplugged, it was still unplugged when you started your second instance of the program.  I'd guess you didn't see the lag on the second instance because one or more errors were generated because some resource (maybe like a COM port) was already tied up by the first instance.  Since you didn't mention getting error when you started your second instance, I'd guess that you are ignoring errors that you should be handling.  Many functions indicate errors in their return variables.  Review your code for functions whose return variables you are ignoring.  Handle them as needed, even if it's just with a dialog box.
    3. "Of course" your supply will always be plugged in?  Have you heard of Murphy's Law?  If it was unplugged for you, it might be unplugged for another user.  Or the fuse may blow or the power supply may die.  You should find a way to detect and report conditions like that, so your user isn't wondering why the program isn't starting.
    4. If you have multiple steps in your program or hardware initialization, you could put up a status bar with messages indicating the current operation, so if the program appears to hang, at least the user has some idea on what the program is trying to do.

  • Why is swing so slow ? :(

    Why java don't use native code for creating UI ?
    Any application, writen in swing is SLOW ...
    compared with .NET for example...
    even well tuned examples a too slow for using.
    I like java, but this $#%ing swing kills all GUI applications.

    The sad truth is that Swing has got such a bad wrap
    that many flock to SWT thinking its the holy grail of
    Java UI development because Swing is so bad. Nothing
    could be further than the truth. SWT is great in many
    respects, but Swing is better in many respects as
    well. If done right, Swing beats SWT in most cases.
    With JDK 1.4.2 improvements are even better, and on
    Mac OS X, Apple works with Sun to build their own
    optimized JVM, so Swing is pretty darn fast, near
    native performance on Mac OS X.
    I wish there was a faster way to get the truth about
    Swing out there. One problem, a lot of developers are
    not the types to accept that they wrote crappy code
    and thus their slow Swing performance is a direct
    result of their bad coding. It's a shame really.
    Accepting that you wrote some crap code only helps you
    get better...well, unless you really do stink at
    programming, then a career change may be in order ;)Well, this about wraps up my feelings about SWT and Swing.
    The problem with many programmers is: they don't like to read.
    Unfortunately Swing is too complex to write a decent program without a concerted effort in reading at a minimum the online tutorials, but to become professional you need a good Swing book.
    Once you get the hang of Swing it is actually better than Visual Basic or MS Access. I have written code generators for MS Access and Ms SQL Server applications. But I like Swing better for many reasons. For example a VB GUI is static, while with Swing you can create a form on the fly. I can go on for a couple of pages of why Swing is so cool, but I simple want to state that statements about Swing should be based on facts, not on some hype.
    Of course Swing can be made easier. That is why Sun is building a product like Rave.
    Swing is here to stay. Within just a couple of years more and more VB programmers will be coding Swing.
    This is good for Swing for the IT industry as a whole, becuase it will mean an explosion in quality products for the consumer market.

  • Swing program - how to increase the size

    Hi Friends,
    I have made a simple swing program and it works fine.But I am not able to make the size(width,height) of the panel.Can someone please tell me how can i do that.Here's some part of my code...
    public class Test extends JPanel
                                 implements ActionListener {
        //instance variable declared here
        public Test() {
            super(new BorderLayout());
            //code for buttons,labels etc
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            add(buttonPanel, BorderLayout.PAGE_START);
        public void actionPerformed(ActionEvent e) {
            //lots of code
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("Test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new Test();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }Thanks for your help.

    OK sorry for that,in future i will post it in the right place.I tried doing this but didn't worked:
           JPanel buttonPanel = new JPanel(); //use FlowLayout
           // buttonPanel.setSize(300, 300);I was followin the FileChooserDemo example from this link:
    http://java.sun.com/docs/books/tutorial/uiswing/components/examples/index.html#FileChooserDemo
    And they used the pack there....now can you help please.

  • Closing the Second instance of the browser.

    Hello,
    I am working on a project written in Java. When applet is running in Browser, we can open the new instance of the browser using File->window->new (or pressing CTR-N). Since the second window runns in the context of first window, It is causing some problem.
    Is there any way for me to close the second instance of the browser from my Java applet?? If not is there any way for me to disable both the File->new->Window and CTR-N options.
    I am new to java and java script. If it is not possible in Java Applet, is it possible in java Script. Please Provide me with full information.
    Thanks and Regards,
    Ratna.

    Hi,
    There is no way you can close the browser window that the user opens. Even if there is a way through some hack, it will not completely give u a solution, independant of browsers and all. And moreover it is not advisable to restrict the user like that.
    A more elegant way would be to handle it in the server side. I can give u one ligical way. U can make the page expire as soon as it gets loaded. U can do that by using the code below. And you have to have a server side function to check for a request from the same client machine for the same page.
    <%
        if (request.getProtocol().compareTo("HTTP/1.0") == 0)
            response.setHeader("Pragma", "no-cache");
        else if (request.getProtocol().compareTo("HTTP/1.1") == 0)
            response.setHeader("Cache-Control", "no-cache");
        response.setHeader("Expires", "-1");
    %>So when the user opens a new browser window, he will be shown page expired message, or the page will be requested again from the server. U can have a map storing the remote address and the session of the user.

  • How do I create a second instance of oc4j in a standalone enviroment

    I am using OC4J standalone to deploy a sparql endpoint using jena, joseki, and the oracle jena adaptor. OC4J is running on the same server as my DEV and QAR databases. The current instance of OC4J is using a data source called "OracleSemDS" to connect to my DEV database. We are now ready to migrate the endpoint to QAR. As I was setting up the QAR endpoint, I discovered the the jena/joseki tools are hard-coded to use the "OracleSemDS" data source. Therefore, I cannot have 2 endpoints running in the same OC4J instance where one points to DEV and the other points to QAR.
    Therefore, I need to create a second instance of OC4J that specifies QAR as the "OracleSemDS" data connection. Can someone tell me how to do that?
    Thanks,
    Phil

    jphilb wrote:
    I am using OC4J standalone to deploy a sparql endpoint using jena, joseki, and the oracle jena adaptor. OC4J is running on the same server as my DEV and QAR databases. The current instance of OC4J is using a data source called "OracleSemDS" to connect to my DEV database. We are now ready to migrate the endpoint to QAR. As I was setting up the QAR endpoint, I discovered the the jena/joseki tools are hard-coded to use the "OracleSemDS" data source. Therefore, I cannot have 2 endpoints running in the same OC4J instance where one points to DEV and the other points to QAR.
    Therefore, I need to create a second instance of OC4J that specifies QAR as the "OracleSemDS" data connection. Can someone tell me how to do that?
    Thanks,
    Philgday Phil -- Melli Annamalai from the Oracle Server PM team pointed me to your question. I was an OC4J Product Manager before we bought out BEA and I swapped over to WLS -- so I have some information below that hopefully is of assistance to you.
    Since you are using OC4J standalone, the simplest way to get a second instance, is to just clone the existing, whole directory structure of your working OC4J instance into another directory, and configure/run it from that directory. To map the OracleSemDS to another target (QAR) you change the data-sources.xml file in the second instance. If you want to run them concurrently on the same server, you'll need to change the ports in the second instance so they have unique values: default-web-site.xml, rmi.xml, internal-settings.xml, jms.xml. These additional ports can be specified on the command line as a Java property string, albeit this is not a documented nor supported feature. See http://buttso.blogspot.com/2007/02/specifying-oc4j-standalone-ports-from.html for more information.
    Now as an example, assuming you have your OC4J you want to clone in the dev directory, and now want to create a second instance of OC4J in qar, I'd do this:
    cp -rp dev/* qar
    cd qar/j2ee/home/config
    vi data-sources.xml
    (edit any other files if needed to alter ports) ...
    cd ..
    java -jar oc4j.jar That should work, and should create the second instance using the current configuration (ie dev) as its basis (including deployed apps). Of course, you'll need to manage them independently from here as they really are just two separate OC4J standalone instances.
    Now what else you could potentially do is to create a secondary configuration file subset only which only changes the necessary files to support running the second instance. In this case, you'd make a copy of the j2ee/home/config/server.xml, j2ee/home/config/application.xml and j2ee/home/config/data-sources.xml files, renaming them to qar-server.xml, qar-application.xml and qar-data-sources.xml.
    Then do the following:
    1. In qar-server.xml file, you'd change the global-application application to point at qar-application.xml instead of application.xml:
    <global-application name="default" path="qar-application.xml" parent="system" start="true" />
    2. Change qar-application.xml so that it used the qar-data-sources.xml file:
    <data-sources path="qar-data-sources.xml" />
    3. Change qar-data-sources.xml file so it points to the qar database target.
    4. Start OC4J, telling it to use qar-server.xml instead of the default server.xml
    D:\java\oc4j-10135-prod\j2ee\home>java -jar oc4j.jar -config config/qar-server.xmlI think you could run into some concurrency problems if you try and run the two instances simulataneously, but in general it should be OK I think if you run them separately.
    Another solution here is look at how the application specifies/uses datasources. The hard coding of the data-source name into the applicaiton via a direct JNDI lookup works, but restricts the flexibility you as a deployer/administrator has.
    If the application used the Java EE resource-ref approach to look up and use the datasource, then the actual JNDI name of the datasource the application uses it totally abstracted from the actual physical name of the datasource that is created on the container -- so you'd have DEVDS and QARDS as physical datasources configured and running on OC4J -- and what happens is that as you deploy the application, you essentially map its lookup and use of OracleSemDS (which would need to change to a java:env/ namespace) to the physical datasource you want it to use (DEVDS or QARDS for example). You can easily alter this post deployment by changing the generated orion-application.xml file to point at the alternate physical datasource. Following that, you can also create separate deployment plans which map the app to the different datasources, then feed this in with the deployment operation so that the correct mapping to either DEVDS or QARDS is done during the deployment process.
    I don't know what scope you have to change the application so the above may not be possible -- you'd need to change the lookup code so that it uses the Java EE reference model and change the meta-inf/application.xml to add the corresponding resource-ref entry which declares the logical datasource name that needs to be mapped on deployment.
    Another approach here may be to use an application embedded datasource, where you put a data-sources.xml file into the application archive itself (along with an orion-application.xml file which references it) whereupon at deployment time, a datasource specific to the application will be created. In this manner, you'd have say two copies of the same application to deploy (DEV, QAR) which contain different data-sources.xml file. From memory, each application will have its own JNDI namespace so their datasources can co-exist with the same names, with application level data-sources overriding server level ones. Since you'll most likely want to keep the same context-root for the web modules (which has to be unique per server) you'll generally need to run just one of the applications at a time. I'd do this like this: deploy one, stop it, deploy the other, stop it, then start only the one you need to test. In that way, you'll have one copy of the application running (either DEV or QAR) and one datasource definition running within it.
    Here's some documentation links to get you going:
    Managing Application Lifecycle (start, stop): http://download.oracle.com/docs/cd/E14101_01/doc.1013/e13978/adminclient.htm#BABHJAFE <-- describes admin_client.jar but general principles apply to ascontrol management of application.
    Packaging and Testing Applications: http://download.oracle.com/docs/cd/E14101_01/doc.1013/e13979/packag.htm#BHCFBEEC
    Application Level DataSources: http://download.oracle.com/docs/cd/E14101_01/doc.1013/e13975/datasrc.htm#CHDIBFHG
    Using Deployment Plans: http://download.oracle.com/docs/cd/E14101_01/doc.1013/e13980/deployplan.htm#CHDFEFAE
    cheers
    -steve-

  • Error while running Swing program on FreeBSD

    Hi,
    I am trying to run simple swing program "helloworld"
    but while executing it gives following error on FreeBSD
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    /usr/local/linux-sun-jdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6:
    cannot open shared object file: No such file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1477)
            at java.lang.Runtime.loadLibrary0(Runtime.java:788)
            at java.lang.System.loadLibrary(System.java:834)
            at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
            at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
            at java.awt.EventQueue.<clinit>(EventQueue.java:80)
            at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1170)
            at JPanels.main(JPanels.java:29)
    Should i install XFree86-libs package on FreeBsd
    configuration
    FreeBSD 4.10-BETA (GENERIC)
    I am using following packages
    linux-sun-jdk-1.4.2.04 Sun Java Development Kit 1.4 for Linux
    linux_base-8-8.0_4 Base set of packages needed in Linux mode (only for i386)
    linux_devtools-8.0_1 Packages needed for doing development in Linux mode
    libtool-1.3.5_1 Generic shared library support script
    gmake-3.80_1 GNU version of 'make' utility
    automake-1.4.5_9 GNU Standards-compliant Makefile generator (legacy version
    GCC 2.95.4
    gdb 4.18
    ld 2.12.1 supported emulation elf_i386
    regards
    Man479

    This is not really a Swing question. You should install the library which satisfies the lookup of libXp.so.6 .
    I quess the jre for this platform is compiled against this version. Looks to me like some X related library, maybe google can resolve a solution/package to install?
    Greetz

  • Running a Swing program from another program

    I'm having what is most likely newbie problems since I'm relatively new to Swing programming. Basically my situation is this: I've got a program that looks at its command line parameters and either runs through a series of actions or presents a Swing GUI to allow the user to step through the actions one by one.
    My problem is that I bascially don't know how to call (instantiate, declare, etc.) the GUI from my Java code. I tried implementing the GUI class with a runnable interface, but evertime I try to invoke the start on the interface I'm getting an error. I have a feeling I'm just missing something. The Swing GUI works fine if I call it on its own so it's the code the invokes it from the small command line processor that I'm goofing up somehow.
    So to recap, I have a small Java app that I'm trying to call a GUI that I've built and can't seem to get the code right.
    Any pointers to examples or explanation on how to accomplish the above are welcome.
    Thanks,
    Ed

    That the "2" is printed out immediately is as expected, but I don't understand why the JVM exits. The following is, AFAIK, a trimmed down version of what you are doing, and if you run it you'll see that the frame remains until you close it manually:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class ShowFrame {
        public static void main(String[] args) {
            AppFrame gui = new AppFrame();
            gui.run();
        private static class AppFrame extends JFrame implements Runnable {
            public AppFrame() {
                setDefaultCloseOperation(EXIT_ON_CLOSE);
                JButton btn = new JButton("Close");
                btn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        AppFrame.this.dispose();
                getContentPane().add(btn);
                pack();
                setLocationRelativeTo(null);
            public void run() {
                System.out.println("1");
                this.setVisible(true);
                System.out.println("2");
    }Maybe someone else can shed some light over your problem...

  • Can I install a second instance of i-Calender on the server where right now is running the first instance? How?

    The first instance is running on a Sun R420 Enterprise
    server. The second instance will run in the same server.

    When you say "Authorized"  you mean in the sense of Itunes Store Authorized? if so the system in Question is authorized it is my primary Workstation and was waiting until iCloud came out to update to Lion. My MBP , and 2006 MP are all running Lion and are part of the 5 systems "authorized". I did not run into this issue with either the MBP or the MP when i installed and I bought two copies at the same time on my the first day Lion was available.
    Do you know the mechanism with which the App Store tracks purchases on different computers prior to iCloud coming out?
    once again thanks for your response
    chris meredith

Maybe you are looking for

  • Error when displaying an internal order

    Hi, I am trying to create an internal order with a particular order type. The internal order gets saved. But while displaying the internal order, I get a message saying "Express document : Update was terminated". The error briefs "ABAP/4 processor: S

  • FPRUNX001 error when fp_docparams-fillable = 'X', else PDF is created.

    Hi, When I use following code, I get FPRUNX001 system error that : Request start time: Sun Dec 23 23:11:47 CST 2007  (200101)... fp_docparams-langu = 'E'. fp_docparams-country = 'US'. fp_docparams-fillable = 'X'. CALL FUNCTION fm_name   EXPORTING    

  • How to send a video to apple support

    Before I contact apple support or while I am communicating with apple support, I would like to send a video of my (problem) screen because it is easier to see what is going on than it is to explain.

  • Vendor material info record

    hi, When am trying to create vendor material info record,i see the<b> valid to</b> is <b>mandatory feild</b> but it is <b>disabled .</b>. i cannot enter any value in that. i:e    In <b>T/C me11</b> after i enter the details in the first screen,click

  • Max size of iBook, ePub images

    Trying to create an eBook with illustrations. Sometime a pic appears on two pages. Is there a stated, maximum size (dpi) for images, so they don't appear on two pages? Is there a way to control things like having caption always appear with pic? The r