Sorry if this is too naive, but shouldn't it be something like eclipse.exe?
The links provided in the comments are quite informative, but if you still aren't able to understand why Eclipse shows as javaw.exe in the Task Manager, then refer to this answer. (Excerpt below)
javaw: (java windowed) Application executor not associated with console. So no display of output/errors. Can be used to silently push the output/errors to text files. Mostly used to launch GUI based applications.
Eclipse is a GUI based development tool and hence the process associated with Eclipse reads javaw.exe in Task Manager.
If you need it to be run as eclipse.exe, you can pass in the following parameter in your eclipse configuration file:
-vm <your java installation folder>\bin\client\jvm.dll
Eclipse is a program, which runs upon Java Virtual Machine. javaw.exe is a process, corresponding to JVM.
Related
Our Java Swing application is running on Windows and wrapped in an exe file using Launch4J.
We would like to customize our application process name and description (in Windows' task manager) as it is currently "javaw.exe" and "Java Platform SE binary" (which is confusing for our customers).
While older versions of Launch4J enabled to change this using <customProcName>, this option is now defunct as it is not working anymore as of Win7.
Is there any other (simple) workaround to customize our application process name and description?
For instance, changing javaw.exe executable filename seems like an approach (as we embed it in the wrapped exe file) but how then indicate to launch4j that the jvm file name changed?
Another option could be to create a launcher exe file: maybe an overkill?
Any ideas / hints are more than welcome; thanks!
If you're looking to roll your own solution, you're going to want to look at JNI and the Invocation API in particular JNI_CreateJavaVM() which is used to create a VM, find the main method GetStaticMethodID() and invoke it with CallStaticVoidMethod.
This is what the java.exe, javaw.exe and a variety of other native launchers do internally. Some examples include:
OpenJDK java.c
IntelliJ WinLauncher.cpp
WinRun4J VM.cpp
If you want don't want to integrate a native build system with your java build system, an approach is to build a static launcher.exe in advance, and treat it as a static binary blob. Then during your java build, modify the binary blob using java, to update the VERSIONINFO, icon and splash screen. An example of this approach can be seen in IntelliJ LauncherGeneratorMain.java
If you can afford it, JSmooth seems to do what you need. It's last released in 2007 though. A note about its license taken from the app itself:
The executable generated (the launchers created by JSmooth) are under the LGPL with a "runtime exception" similar to the gcc licence exception: It is not required that you distribute the source code with it, nor that you publish a notice mentionning jsmooth.
When using JSmooth, there is a section labeled "Skeleton" that allows you to select some pre-defined parameters. One of them is a "Windowed Wrapper" that is fit for GUI applications described as follows:
This skeleton wraps GUI applications.
No console I/O is displayed
If no Java VM is found, it is able to display a configurable URL (typically to a java download page).
Arguments can be passed to the application (either use the JSmooth default argument mechanism, or create a shortcut with arguments).
The important thing in this skeleton is to check the option "Launch java app in the exe process" which results in running the JVM in the same process as the wrapper exe. This means only the exe is shown in the Windows Task Manager, as opposed to both the exe and the java process.
The alternative is to write your own wrapper. See this Oracle guide for how to invoke the JVM from a native application.
I did similar things with WinRun4J, as far as I remember it can be used commercially because it is CPL licensed. Checked this today: settings the process name still works (initially did this on XP) with Windows 7.
According to the website you simply create a ini file which tells WinRun4J what to run:
main.class=org.something.MyMainClass
classpath.1=*.jar
(there are many more parameters, you can set where the JRE can be found and more)
In a second step you copy the winrun4j.exe to something that fits your application:
copy winrun4j.exe yourapplication.exe
(There is a version for Windows x64 too)
Then you have RCEDIT (comes with WinRun4j) add the ini to the exe:
rcedit /N yourapplication.exe yourapplication.ini
This seems pretty old, and not really worth the effort, but it may also be what you are looking for: Java exe Maker.
What i already have:
Using eclipse keppler i am creating an eclipse plugin that is to work under linux, windows and mac.
I am trying to wrap some existing java code into this eclipse plugin. This works fine. The execution of the wrapped code can be started by clicking a button in the plugin ui. The wrapped code uses some environment variables. When these are set as environment variables and eclipse is then started the variables are found and used.
What i would like to do:
I would like to set the required environment variables in some textfields in the plugin ui and then start the execution of the wrapped code which should then use the variables form the textfields, so that i no longer need to set them as environment variables before starting eclipse. This would obviously be more flexible.
This feature is used by the eclipse ide itself when starting a run/debug-process. For these processes the environment variables can be set. This is the mechanism i would like to use.
My questions:
How is it possible to start a process from an eclipse plugin and provide it with a set environment variables that are set in the plugin ui?
Is it necessary to use ProcessBuilder or Runtime.exec() or is there some java-only solution?
Is the only way to find an answer to search through the eclipse souce code?
How is it possible to start a process from an eclipse plugin and provide it with a set environment variables that are set in the plugin ui?
Get the env variable names and values from your plugin UI.
Use ProcessBuilder or Runtime.exec() to launch a new (external) process with the appropriate environment variables.
(The 2nd step is the same as what you would do if you weren't using Eclipse.)
There may also be an Eclipse-specific way of doing this, but underneath the hood that will have to use ProcessBuilder or Runtime.exec().
Is it necessary to use ProcessBuilder or Runtime.exec() or is there some java-only solution?
If you want to run the Java code as a separate process, then at some level you have to use ProcessBuilder or Runtime.exec(). Conversely, while it is possible to run a Java application in "the current JVM", you won't be able to change the environment variable settings for the current application. (The Map you get from System.getEnv() is documented as "not modifiable".)
(I'm not sure what you mean by "java only". You could argue that one JVM launching another using ProcessBuilder or Runtime.exec() is "java only".)
Is the only way to find an answer to search through the eclipse souce code?
No. You could also find the answer by reading the javadocs ... like I just did :-)
I installed Netbeans on OSX Mountain Lion running JDK 7. Everything was working fine. Then my machine for no reason crashed. After this I could no longer open Netbeans anymore.
If I try to start Netbeans from the commandline:
/Applications/NetBeans/NetBeans 7.2.app/Contents/MacOS/netbeans
Then it works fine. From there I can select Netbeans > About and confirm that my userdir and cachedir is:
User directory: /Users/<user>/Library/Application Support/NetBeans/7.2
Cache directory: /Users/<user>/Library/Caches/NetBeans/7.2
So, I deleted these directories and tried again, but alas, I can only start netbeans via the commandline.
Ideas appreciated...
Sounds to me like this is not a NetBeans problem at all, rather a problem with the bundle, such that OS X is not launching the app as it should.
To verify, I'd try opening NetBeans through Finder from the command line:
open -a "NetBeans 7.2.app"
This command will ask the system launcher to open the application as if you had clicked on the icon. In your case, it probably won't open. If this is true, then you know it's not something in your terminal environment that's allowing NetBeans to launch.
The next step that I would take would be to look at the package contents: examine /Applications/NetBeans/NetBeans 7.2.app/Contents/Info.plist for anything that seems amiss - this file is the information store that OS X looks for to see how to launch the package, what its icon is, etc... - in particular, I think you should look at the CFBundleExecutable value to see what command is used to launch the app. If it's not netbeans, you've found a big hint on what might be amiss: bundles are set up so that launchers should run bundle_dir.app/Contents/{platform}/{CFBundleExecutable_value}. Looking at CFBundleExecutable should show you if there's some other script used to launch the app than just running netbeans.
From this point, you'll have to do more digging, but hopefully this is enough information for you to get started tracking down how apps are launched from the OS X launcher. For more info and a better reference, check out this link, which is Apple's documentation for keys in Info.plist.
Finally, you should note that the launch information for all apps are heavily cached; I've heard that if you make a change to Info.plist, you have to rename the app bundle and name it back to have the changes picked up by the launcher.
Good luck!
Here's an idea: use Eclipse >=)
..but seriously, something got corrupted in Netbeans' metadata/cache data files. You cleared a couple of them but there may be others elsewhere.
Try comparing the launch command in your shortcut to what you're typing in the console. Are they the same?
To find the root cause, I would check the NetBeans logs, as detailed here
/Users/yourname/Library/Application Support/NetBeans/7.2/var/log/messages.log
And if that doesn't help, I'd archive your project(s) and put a clean install of NetBeans on your machine, and then import the archived project(s) back into NetBeans.
is there a way to display, in Eclipse, the full command line that is used to execute a java application?
I am using Juno.
Thanks in advance.
I'm not sure what you're asking, but if you're looking for the full command line of the current execution, I'm not aware of a place you can see that in Eclipse. If you are on Windows though, I'd recommend SysInternals (now Microsoft) Process Explorer. Below is an example of the properties of a process I started in Debug mode from Eclipse.
I'm in the process of porting simple console apps written in C++ to Java in order to show how similar the languages are, and how code can be ported. I've exported executable JARs for the programs using Eclipse. These JARs work fine when they are run using the java -jar command. However, they do not run properly when executed from windows explorer (double clicked). A console window simply opens and closes rapidly.
The only solution I have found thus far is to use a batch file. Is there any other option?
There are some options:
Sleep a bit when the program is done, so you can read the output.
Call System.in.read() (again at the end of the program), which will wait until you type a char and hits enter.
Create your own little swing terminal, which doesn't close when the application code is done.
This seems like the jre used from the command line and from the registry are not the same (this can occur when multiple JRE's are installed)
Have you checked in your windows registry what is the jre used to run the executable jars ?
You can find more on the registry settings on sun's site
Seems to me that your main class does not even gets executed.
This would explain the quick open/close of console window.
Or is it possible that another program than java has the "jar" file type?
Happened to me after installing a Nokia software.
Using a batch file seems to be my best option. I suppose that's why Eclipse has a launcher.
Change the open with program to
c:\Program files\java\jre7\bin\javaw.exe