I have a program in Java (with a swing gui), and I would like only 1 instance ever to exist. If it attempted to open another instance of the program I would like the current instance to be brought to the foreground.  How do I do this?  Thanks in advance.
37207
Sometime I see many application such as msn, windows media player etc that are single instance applications (when user executes while application is running a new application instance will not created).  In C#, I use Mutex class for this but I don't know how to do this in Java.
42370
What is the most recommended/best way to stop multiple instances of a setTimeout function from being created (in javascript)?  An example (psuedo code):  function mouseClick() {    moveDiv("div_0001", mouseX, mouseY); }  function moveDiv(objID, destX, destY) {    //some code that moves the div closer to destination    ...    ...    ...     setTimeout("moveDiv(objID, destX, destY)", 1000);    ...    ...    ... }   My issue is that if the user clicks the mouse multiple times, I have multiple instances of moveDiv() getting called.  The option I have seen is to create a flag, that only allows the timeout to be called if no other instance is available...is that the best way to go?  I hope that makes it clear....
14607
How can I open more than one instance of the Windows settings?  It wasn't a problem with the old style, but with the new one I can't seem to open multiple settings simultaneously and side by side.  Example of the new settings window:
24218
Is this functionality going to be put into a later Java version?  Can someone explain why I can't do this, as in, the technical way Java's switch statement works?
16261
How do I run a program in the background of a shell, with the ability to close the shell while leaving the program running? Lets say my UI is having problems or for some reason, I need to boot up a program from the terminal window, say, nm-applet:  nm-applet   When it's started, it occupies the foreground of the terminal window.  Is there any simple way to run the program in the background without needing to leave the terminal open or have it occupy the whole terminal?  On that note, I did find a way to run programs from the terminal and have it allow for other inputs, by appending an ampersand (&amp;) to the command as such:  nm-applet &amp;   But this isn't much use as any processes started in the terminal are killed once the terminal is closed.
71378
I have a JAR file named helloworld.jar. In order to run it, I'm executing the following command in a command-line window:  java -jar helloworld.jar   This works fine, but how do I execute it with double-click instead? Do I need to install any software?
61998
We have a custom java web app. We are setting it up in instances in different vps (different providers, different locations). We have for example:  Instance 1: http://server1/app1 Instance 2: http://server1/app2 Instance 3: http://server2/app3   Each instance is independent and self contained. We have several docens of this instances and will continue to add them.   My question is regarding the dns managment, as we want to map different subdomains to the instances.   client1.mypp.com  &gt; http://server1/app1 client2.mypp.com  &gt; http://server1/app2 client3.mypp.com  &gt; http://server2/app3  clientN.mypp.com  &gt; http://anyserver/appN   Right now we are adding the A records manually to the DNS records to relate subdomain to the ip. We will develop some code to do it using the API of the DNS provider.   Is this the most appropiate aproach? Should we use some kind of proxy instead? We expect to have thousands of isntances accros different servers. I am interested in perfomance and availability.
53822
I have a command, let say php process.php. I want to run 1000 instance of this command to test load caused on the server. How can I do this?  Things to note:   Ctrl+C should terminate all instance at once It is going to run on a single core processor so no need of advance feature like multi-threading. Nice to show current number of running instance on top Commands should output in the same terminal Commands requires no input
37596
Say I have a class that's meant to perform a single function. After performing the function, it can be destroyed. Is there any reason to prefer one of these approaches?  // Initialize arguments in constructor MyClass myObject = new MyClass(arg1, arg2, arg3); myObject.myMethod();  // Pass arguments to method MyClass myObject = new MyClass(); myObject.myMethod(arg1, arg2, arg3);  // Pass arguments to static method MyClass.myMethod(arg1, arg2, arg3);   I was being intentionally vague about the details, to try to get guidelines for different situations. But I didn't really have in mind simple library functions like Math.random(). I'm thinking more of classes that perform some specific, complex task, but only require one (public) method to do it.
121
I always thought Java uses pass-by-reference. However, I've seen a couple of blog posts (for example, ) that claim that it isn't (the blog post says that Java uses pass-by-value). I don't think I understand the distinction they're making. What is the explanation?
3073
How can I create an instance of the Java console inside of a GUI panel?
11867
My singleton accessor method is usually some variant of:  static MyClass *gInstance = NULL;  + (MyClass *)instance {     @synchronized(self)     {         if (gInstance == NULL)             gInstance = [[self alloc] init];     }      return(gInstance); }   What could I be doing to improve this?
47307
Currently, if I want to tile two instances, I press the green button on the top-left and place the instance accordingly. However, each of the tiled instances always go into full screen mode. For a chrome instance, this is annoying as it means it's not possible to see the tabs. How do I tile windows without making them go  full screen?
114399
How would you open a file (that has a known file/app association in the registry) into a "running instance" of the application it's supposed to open in? An example would be, I have Excel open and I click on an XLS file.....the file opens up in the current Excel instance. I want to do this for a custom application...how does the eventing/messaging work that "tells" the current instance that it needs to open a file? Is there a "file watcher" that looks for a request to do so etc? Thanks..
51358
How do you decide between passing arguments to a method versus simply declaring them as object instance variables that are visible to all of the object's methods? I prefer keeping instance variables in a list at the end of the Class, but this list gets longer as my program grows. I figure if a variable is passed often enough it should just be visible to all methods that need it, but then I wonder, &quot;if everything is public there will be no need for passing anything at all!&quot;
92098
When a java based application starts to misbehave on a windows machine, you want to be able to kill the process in the task manager if you can't quit the application normally. Most of the time, there's more than one java based application running on my machine. Is there a better way than just randomly killing java.exe processes in hope that you'll hit the correct application eventually?  EDIT: Thank you to all the people who pointed me to Sysinternal's Process Explorer - Exactly what I'm looking for!
106772
I would like to mimic the use of Alfred on Mac OS X, where if you try to open an app after searching for it, it will only open a new window if the program is not already running, otherwise it will set the focus on the currently running instance of that application. Is there anyway to change the default behavior of the launcher to check for this before opening a new window?