I want to increase the initial RAM allocated to run a particular jar that needs it. However, passing the parameter "-xms1g" to the system JRE seems to prevent the launch of a JNLP file that I need to submit credentials for access to the U.S. Patent Office Private PAIR website:
https://ppair.uspto.gov/TruePassWebStart/AuthenticationChooser.html > "Authenticate with Java Web Start (new method)".
When the JNLP launches properly, it opens a GUI that prompts you to entire the filename and path of a certificate in one field, and a password in another field, and then it automatically closes and brings up the private PAIR website in your web browser, if your credentials are valid. You don't have to have a certificate or password to duplicate or test for my issue, as my problem is not getting the prompt to pop up.
For consistent testing and development of my jar, I want to run it on the latest JRE release, which I have to assume other users of my jar will be running. I believe I may also need to use the latest JRE release when launching the JNLP to access the USPTO, for security reasons. Maybe someone who understands cyber-security better than I do could tell me that JRE version doesn't matter when I am launching a JNLP file instead of running an applet through the Java browser plugin (the so-called "old method"), the latter plugin being what Google Chrome stopped supporting, but I don't want to assume that.
So ideally I would like to have two installed instances of the same (latest) JRE version and pass the -xms1g parameter only to the instance I use to run my jar, not to the (system) instance that launches the JNLP. Is this possible? When I tried executing the JRE installer twice, selecting different folders, I found that the second installation had deleted everything from the first folder.
So ideally I would like to have two installed instances of the same (latest) JRE version and pass the -xms1g parameter only to the instance I use to run my jar, not to the (system) instance that launches the JNLP. Is this possible? When I tried executing the JRE installer twice, selecting different folders, I found that the second installation had deleted everything from the first folder.
You do not need two installations of the same JRE to run different java processes with different options. Ensuring that is the purpose of providing them as command-line options. You can choose the non-default options you want when you launch the JVM, whether by configuring them in a shortcut, recording them in a launch script (taking the form of a batch file on Windows), or typing them manually on the command line.
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.
I have an Eclipse RCP GUI application and I've been trying to redirect all files needed at run-time to a folder in the users home directory.
My issue arises when trying to move the configuration folder using the "-configuration" program argument.
When I just use data it works, my app starts up normally, but when I add in the configuration argument this thing opens when I run the app instead:
This is likely because Subclipse's default policy for usage statistics is set to 'ask'. Now that you are changing the configuration area to a location where no configuration settings are stored, Subclipse - when activated - shows this dialog.
Though Subcipse is violating Eclipse UI guidelines here, the maintainers probably won't change this any time soon.
If your RCP application does not depend on Subclipse, you should remove the respective plug-ins or features form your target platform and the problem will go away.
I'm trying to create a portable environment (USB Flash/Disk) that can be copied from one device to another - and work "out of the box" on a Mac/OSX (10.10.x environment) specifically. My purpose for this, is I'm teaching a "Portable Programming" class next semester, and I want to be able to just copy (or give the student a .zip file), have them expand it on a specifically named volume, and the environment works. This includes the SDK version(s), AVDs, etc. I've got everything apparently working (so far), but have a problem with the AVDs.
This is a new install, using latest Eclipse, etc.
I'd hoped to find these directories, etc. within an XML/INI file, and use an editor or sed to change the strings, but can't seem to find the directory names of anything I've needed to change so far within an XML/INI file within the unzipped Android directory - but don't see them.
I do see a reference within Preferences->Android->Build "Default debug keystore" that references ~./android - but it is not editable. There IS a "custom" debug keystore setting on the same dialog page, but changing it does not seem to have an effect on the AVDs and their location. So far, that's the ONLY reference I've found for my home directory. I've looked at the Eclipse CLI at eclipse.org, but don't seem to see anything relating to this issue (at least not anything that's ringing a bell with me).
So - how can I change my default "home" directory (without boogering up the environment, etc.) for Eclipse/Android, so my AVDs (and whatever else I HAVEN'T run into yet), can be installed and used/run from the USB drive/stick?
Please - I DO NOT WANT links to other "portable" packages, as I'm not sure what's actually been altered in them (and probably not current, and an update is likely to hose everything anyway), and don't want to pass along anything to students. I'm downloading official packages from official locations, and want to keep it that way. So I'm only looking for things that can be fixed/edited within an officially installed environment to get the effect I'm looking for. Thanks!
Found this at Launch mac eclipse with environment variables set
There is an alternate solution which involves replacing the executable that is run by MacOS X when the user launches the Eclipse application with a shell wrapper that sets up the environment.
Create an empty text file called "eclipse.sh" in the Eclipse application bundle directory /Applications/eclipse/Eclipse.app/Contents/MacOS.
Open the eclipse.sh in a text editor an enter the following contents:
#!/bin/sh
export ENV_VAR1=value
export ENV_VAR2=value
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
In the example ENV_VAR1 and ENV_VAR2 are the environment variables being set up. These variables will be visible to processes launched from within Eclipse. The logger command will just log the path of the eclipse executable to the system.log as a debugging aid.
In the Terminal set the executable flag of the shell script eclipse.sh, i.e.:
chmod +x /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.sh
Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh.
MacOS X does not automatically detect that the Eclipse.app's Info.plist has changed. Therefore you need to force update the LaunchService database in the Terminal by using the lsregister command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app
The next time you launch Eclipse.app from the Dock or from the Finder the environment variables should be set.
It took me a while to research, as that info was from Sep. '09, which was back in Snow Leopard (OSX 10.6) days. I'm now running 10.10, and while some things don't change - a LOT has changed, so it took a while to research the above approach and make sure it wasn't going to do some potential damage to the installation. A LOT of under-the-cover stuff has changed in those 4 versions, and I wasn't willing to just take off with it. I've also not found a good explanation of exactly what ANDROID_SDK_HOME actually controls - although this above approach seems to work - so far.
I have two different versions of eclipse that both quit working on me, I am using windows 7 home premium, the versions of eclipse that I have are Eclipse Luna 4.4 and Eclipse Juno. I have done the following things to correct the error but I am not getting a crash report or anything. In the following order I have tried:
Restarting my computer,
Deleting eclipse and reinstalling,
From command running
Eclipse.exe -clean
Eclipse.exe -clean -clearPersistedState
Eclipse.exe -debug
I have also checked my JAVA_HOME environment variable which is properly set, and the PATH environment
Variable which is also properly set. Still not sure what is going on.
:::EDIT:::
Ok I did Find a report on my windows compatibility checker saying that the application
is incompatible with windows and the repair the issue section failed to repair it.
I do know that two days ago I was working in the eclipse environment without a problem.
When I got home yesterday my machine showed that there had been new updates installed. I
didn't have any issues until yesterday. So I guess my next question is how do I find what
made the application incompatible with my machine, and if it was the updates how do I reverse
them so that I can get my IDE back, I could switch to Netbeans But I prefer to not have to do
so It just doesn't make any sense to do so if I could somehow manage to get eclipse working
again.
all give me the same result, a quick flicker of what I imagine is the Eclipse splash screen and that is it, so my question is where might I find a crash or debug report (if one is generated by eclipse) other wise does any on have any idea what may be happening.
THANKS..
Running Eclipse
After installing the Eclipse SDK in a directory, you can start the Workbench by running the Eclipse executable included with the release (you also need at least a JDK6 or JRE 6, not included with the Eclipse SDK). On Windows, the executable file is called eclipse.exe, and is located in the eclipse sub-directory of the install. If installed at c:\eclipse-SDK-4.4-win32, the executable is c:\eclipse-SDK-4.4-win32\eclipse\eclipse.exe. Note: Set-up on most other operating environments is analogous. Special instructions for Mac OS X are listed below.
Allocating enough memory and solving OutOfMemoryErrors
By default, Eclipse will allocate up to 384 megabytes of Java heap memory. This should be ample for all typical development tasks. However, depending on the JRE that you are running, the number of additional plug-ins you are using, and the number of files you will be working with, you could conceivably have to increase this amount. Eclipse allows you to pass arguments directly to the Java VM using the -vmargs command line argument, which must follow all other Eclipse specific arguments. Thus, to increase the available heap memory, you would typically use:
eclipse -vmargs -Xmx
with the value set to greater than "384M" (384 megabytes -- the default).
When using an Oracle JRE, you may also need to increase the size of the permanent generation memory. The default maximum is 64 megabytes, but more may be needed depending on your plug-in configuration and use. When the VM runs out of permanent generation memory, it may crash or hang during class loading. The maximum permanent generation size is increased using the -XX:MaxPermSize= argument:
eclipse -vmargs -XX:MaxPermSize=
This argument may not be available for all VM versions and platforms; consult your VM documentation for more details.
Note that setting memory sizes to be larger than the amount of available physical memory on your machine will cause Java to "thrash" as it copies objects back and forth to virtual memory, which will severely degrade your performance.
Selecting a workspace
When the Workbench is launched, the first thing you see is a dialog that allows you to select where the workspace will be located. The workspace is the directory where your work will be stored. If you do not specify otherwise, Eclipse creates the workspace in your user directory. This workspace directory is used as the default content area for your projects as well as for holding any required metadata. For shared or multi-workspace installs you must explicitly specify the location for your workspace using the dialog (or via the "-data" command line argument).
Specifying the Java virtual machine
Here is a typical Eclipse command line:
eclipse -vm c:\jdk7u45\jre\bin\javaw
Tip: It's generally a good idea to explicitly specify which Java VM to use when running Eclipse. This is achieved with the "-vm" command line argument as illustrated above. If you don't use "-vm", Eclipse will look on the O/S path. When you install other Java-based products, they may change your path and could result in a different Java VM being used when you next launch Eclipse.
To create a Windows shortcut to an installed Eclipse:
Navigate to eclipse.exe in Windows Explorer and use Create Shortcut on the content menu.
Select the shortcut and edit its Properties. In the Target: field append the command line arguments.
Opening this shortcut launches Eclipse. (You can drag the shortcut to the Windows Desktop if you want to keep it in easy reach.)
Mac OS X
On Mac OS X, you start Eclipse by double clicking the Eclipse application. If you need to pass arguments to Eclipse, you'll have to edit the eclipse.ini file inside the Eclipse application bundle: select the Eclipse application bundle icon while holding down the Control Key. This will present you with a popup menu. Select "Show Package Contents" in the popup menu. Locate eclipse.ini file in the Contents/MacOS sub-folder and open it with your favorite text editor to edit the command line options.
On MacOS X you can only launch a UI program more than once if you have separate copies of the program on disk. The reason for this behavior is that every UI application on Mac can open multiple documents, so typically there is no need to open a program twice. Since Eclipse cannot open more than one workspace, this means you have to make a copy of the Eclipse install if you want to open more then one workspace at the same time (bug 139319).
If you need to launch Eclipse from the command line, you can use the symbolic link "eclipse" in the top-level eclipse folder. It refers to the eclipse executable inside the application bundle and takes the same arguments as "eclipse.exe" on other platforms.
On Mac OS X 10.4 and later, you may notice a slow down when working with significant numbers of resources if you allow Spotlight to index your workspace. To prevent this, start System Preferences, select the Spotlight icon, then the Privacy tab, then click the Add button ("+") and find your workspace directory in the dialog that appears.
Shared Install
The startup speed of a shared install can be improved if proper cache information is stored in the shared install area. To achieve this, after unzipping Eclipse distribution, run Eclipse once with the "-initialize" option from an account that has a write access to the install directory.
I tried following various tutorials for getting a JavaFX hello world app running in a browser. I can't believe it's that hard, so I'm looking for any insight into what I may have done wrong. Some things I've tried and resolved (to rule out the obvious):
Had to download 32-bit JRE for the browsers and ensure they were using that
Thus using the latest JRE (7u21); running on Win 7 64-bit
Checked Windows Control Panel -> Programs -> Java to verify the JRE being used
Signed the JAR file
Tried running from local file, found that drive letters weren't recognized, so moved to running via Tomcat 6
Tried various changes to the codebase and url hrefs, but I believe those are correct.
Tried in both IE 10 and Chrome
What I ended up with was that loading the .html (which references the jnlp using the JavaFX default javascript) would spin for a while then fail. If I try to load the .jnlp file directly, I get an exception:
ClassNotFoundException: javafx.application.Application
I verified that the jfxrt.jar is in the lib folder of the JRE that the browser is using.
Any insight/suggestions as to what I may be missing at this point? Seems like it must be something obvious/basic at this point, but I'm not seeing it. Thanks.
Just to follow-up, I went ahead and used javafxpackager. That produced a web page that would load the JavaFX application in Chrome. However, it still doesn't work in IE. I'm going to write that off as an IE but since it works in Chrome. What I did learn by looking at the results, though, is there are several things javafxpackager does, and the results of that are not exactly what's described in most of the manual tutorials/examples. Minor differences, but apparently they matter.
It sounds as you don't have the JavaFX starter classes in your JAR (usually done by the Ant script) and don't have the correct JavaFX Manifest entries.
It should not be needed to add the jfxrt.jar as a resource to your JNLP file and you shouldn't have to sign it.
Please show your Manifest file.
The Manifest file should contain at least the following JavaFX entries:
JavaFX-Version: 2.2
JavaFX-Application-Class: yourPackage.YourApplication
Main-Class: com/javafx/main/Main
The JAR should contain the classes of the com.javafx.main package provided by the ant-javafx.jar (see /resources/classes in that Jar). The ant-javafx.jar is provided by the JDK.
I was able to mostly resolve my problem. I'm using Eclipse, not NetBeans, so doing a lot manually. The basic problem was that I had to include the jfxrt.jar as a resource in the jnlp file (and that jar also had to be signed).
My app now runs if I access the jnlp directly, though it still doesn't work via html page. I'll post an update if/when I figure that part out.