How do I run multiple instances of a JMS program in Eclipse? - java

I copied a sample Chat application from http://onjava.com/pub/a/onjava/excerpt/jms_ch2/index.html?page=2 I also got it to compile and run under GlassFish. Unfortunately to see the program in action you need to run multiple instances of it, passing different user names as command line arguments.
I know how to pass command line arguments to a program in Eclipse. I can also run different configuration settings for the same program at once. But instead of opening a different Console window, Eclipse uses the same console window for everything (including the GlassFish server). To make matters worse, Eclipse switches between the different users automatically. That is, once I type a message in the Chat application under one user name and press Enter, Eclipse will automatically switch to different user's console window.
I need distinct console windows for each instance of the program that I run. Is there a way to do this in Eclipse? Alternatively, is it possible to start the GlassFish server in Eclipse and then run the program outside of Eclipse? (Note: The GlassFish server was installed through Eclipse, not as a separate server).

You can run a server in Eclipse and then run your program outside of Eclipse.
For the console: Each application you run in Eclipse gets its own console window. You can switch them with one of the icons in the console view (it looks like a monitor). However, Eclipse "reuses" console windows of terminated applications.
If you want to have multiple side-by-side, see In Eclipse, can I have multiple Console views at once, each showing a different Console?
Eclipse always switches to the "active" console in its stack of consoles. You can turn this behavior off with "Show Console When Standard Output Changes" icon.

Related

IntelliJ - "SnapShooter listening on port XXXXX"?

I am attempting to run a Java program and all of a sudden, whenever I run it I get a message like "SnapShooter listening on port 40182" at the beginning of the standard output stream. The code runs fine, it's just that the message always appears. What is SnapShooter? Is it some sort of malware?
No, it is not malware; malware typically does not announce its presence via a message to your standard output. SnapShooter it's a component that is used to capture snapshots of Swing UI forms in the application you run from the IDE. The message is displayed because you checked the "Enable capturing form snapshots" checkbox in your run configuration settings, and will go away if you uncheck it.

Java Web Start doesn't launch my .jar without enabling the "show console"

As stated in the title, my software won't launch unless the "Show console" option is selected in Java settings. I'm not sure what kind of code you'd like me to post, so please ask.
When I try to run it, the Java dialog pops up and the progress bar that loads the software completes before it closes. When the console is up, the software finally loads and displays afterwards. Without the console, nothing happens.
I've tried to run the web start on different computers, and they all had the same problem. The console doesn't print out any error messages, so I don't have anything to use for debugging the problem.
Some information about the software:
It's a JavaFX project, compiled using Oracle jdk 1.7.0_65 on OS X with Netbeans. It requires full security permission, and all jars (I use a bunch of libraries) are being signed using a key store from a trusted vendor.
EDIT
I tried to launch my program through console using the following command: javaws -viewer http://www.website.com/software.jnlp, and - without launching my software - it returned the following result to the terminal:
java.lang.NullPointerException
at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1003)
at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:998)
at sun.awt.SunToolkit.getSystemEventQueueImpl(SunToolkit.java:993)
at java.awt.Toolkit.getEventQueue(Toolkit.java:1749)
at java.awt.EventQueue.invokeLater(EventQueue.java:1245)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1290)
at com.oracle.deploy.update.UpdateCheck.updateStateChange(Unknown Source)
Could this be of any help?
For others who might have this problem, this is what caused it for me:
I had a thread running in the background that would show the stage once it was done loading all the assets. This stopped the whole thing from executing, so I had to change the loading logic inside of my code instead to allow for the primary stage to use the show-method in the UI-thread.

Cannot run two instances of java webstart

I am unable to run more than one instance of java webstart at any given time.
For example, I am unable to run both the production & QA instance of an application at once, both of which are launched via java webstart. Additionally, I am unable to run the java webstart cache viewer at the same time as either the production or QA instance of my application.
I am however able to run any of the above three webstart launches when they are run in isolation of each other. When I try to bring up a second option, I see the 'Java Loading...' screen which then disappears and nothing happens.
Additionally, I have tried to delete the webstart cache (via the java webstart cache viewer) and I receive the following error regardless of which JRE I point to:
"Bad installation. Error invoking Java VM (execv)
'path to my javaw.exe'"
I expect both the problems I mention above are interlinked. I do not believe I have changed any configuration recently and I have been happily running java webstart for years.
Has anyone seen such a problem before?
Thanks,
Jack
EDIT: When the second instance of webstart attempts to run, during the display of the 'Java Loading...' screen I can see in the task manager that a new javaw.exe process is spawned. This process almost immediately dies though. I'm not sure how to inspect the failure in that process, but I expect it is similar to the failure when trying to clear my cache through the webstart cache viewer.
You may be able to use javaws from the command line to run a second instance in -offline mode. The verbose option is handy, too.
javaws -offline -verbose MyApplication.jnlp
I think it is because both instances of the application use the same folder as current working directory. I do not remember exactly but it is somewhere under user home and the folder contains the application name or something...
So, if this is correct the solution is to change the application name like "My Application - QA" vs. "My Application" used on production.
The name is somewhere in jnlp.xml.
The reason may be the startup parameters for client java/javaw, which do not allow to run more than one instance of Java. For example because of set debug port. These parameters can be set in the command line or in the Java Control Panel -> Java -> button View.

When I run a program with Java Web Start, it doesn't show me the errors

I configured Netbeans to run a program with Java Web Start.
The program compiles fine, but then when it runs, it tries to load a file (a sound clip) that was not in the place it expected to find it in. Here Java Web Start just pauses. It doesn't show me any errors, either in the output tab of Netbeans, or in the Java Console (which is what it shows me when I open the html page and run it as an applet).
Any idea how I can configure things so that errors are displayed?
Whenever you deal with Java WebStart it is really nice to enable the Java Console (see Control Panel -> Java under Windows), and turn on full debug log.
Am I right in assuming you are looking for a stack trace?

How can I easily make a java application invisible to the user?

I have developed a Java aplication that is currently being run by double-clicking on a ".bat" file that does something like "java -jar proy.jar". This application just listens on a port and writes to a database, so it does not have any user interface (such as a window). I need this application to run as in background mode, or as it were a service, but I don't really anything more than that. It's enough if the application is run in a way that is not noticeable by the user, so that the user is not bothered and so the application can not be mistakenly closed. By the way, this will be run on an specific computer so it's okay if I have to do any manual configuration ir order to make this work. Also, I need this application to run on startup.
Any help/tips regarding this?
In advance, thank you very much for your help!
Regards,
Pedro
use javaw.exe instead of java.exe and you will not get a console window.
from the java.sun.com:
The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.
EDIT:
A .bat will start a console. If you can live with a console up for a fraction of a second, you can preface your call to javaw with start. This will spawn another console-less process for javaw and allow the console-ful bat to exit.
You can run your application as a System Tray icon (Java 1.6) if you are targeting Windows environment. Allow a context-sensitive menu trigger when clicking on the System Tray icon for the user to select a few options.

Categories

Resources