I am trying to do some automated testing with selenium on a site that has a java applet. Specifically, I want to test different java versions on different browsers.
It is relatively easy to change the jre that is being used by local applications/commandline - usually just a modification of the PATH and perhaps a registry tweak (HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Runtime Environment/CurrentVersion seems to need to be changed sometimes).
But I can't seem to manage to change what a browser applet uses. It is my understanding that this version is determined by the plugin for that browser. I've tried to get around this by actually uninstalling all the jre on the machine, then installing the specific version I want to test. However, I need java to be available at all times so I am preserving a jdk (1.8.0_25).
This works, sometimes. Recently I've been trying to install jre7 (update 71 and update 72) but neither installation seems to affect the version of java used in the applet. In firefox, the add-ons page shows Java (TM) Platform SE 7 U72 10.72.2.14 under plugins, and yet it is running 1.8.0_25 in applets (from http://javatester.org/version.html)
My question is: how can I ensure that a specific version of java is running in browser applets? Sorry if my situation is a bit confusing - I've tried cutting it down to the bare minimum.
OS: Windows 7 Enterprise
Browsers: Chrome 39.0.2171.71 m, FF35.0, 33.0, 27.0, IE8
Reference Java Control Panel
Java
The Java panel looks like this:
Click the View... button to access the Java Runtime Environment
Settings dialog. Java Runtime Environment Settings
These settings will be used when a Java application is launched. The
Java Runtime Environment Settings dialog looks like the following on
Microsoft Windows:
Each row in the Java Runtime Versions panel represents a Java Runtime
Environment that is installed in your computer. You may modify the
value in each cell by double-clicking it:
Platform: The version of the Java Runtime Environment
Product: The full version number of the Java Runtime Environment (which includes the update number)
Location: The URL that Java Update Scheduler uses to launch automatic updates
Path: The full path name of the Java Runtime Environment
Runtime Parameters: Optional custom options used to override the Java Plug-in default startup parameters
Enabled: This option is for selecting which of the (older) JRE versions to consider when running an app using Java Plug-in or Java
Web Start. If this check box is not selected, then Java Plug-in and
Java Web Start will not use this JRE to launch Java apps. However, the
current JRE might be used regardless of this checkbox. This checkbox
does not affect stand alone applications, it is only for Java in the
browser. Note that if all Java apps are disabled from running in the
browser, by de-selecting Enable the Java content in the browser in the
Security panel, enabling the JRE here has no effect.
Use the Enabled checkbox to select which JRE to use when running an app using Java Plug-in or Java Web Start.
Related
Running java_home shows:
> /usr/libexec/java_home -verbose
Matching Java Virtual Machines (1):
1.7.0_45, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
But the Java Control Panel says:
What gives? Can anybody explain?
Basically, Mac OS X starts out without any Java, and if any installed application or web site requires Java, it allows you to install a Java JRE.
The JRE is installed with a plain, non-programmer user in mind. It is a runtime environment, has no associated development tools, and includes the Java Webstart. It also comes with a control panel that allows a user to control things such as security, updates etc.
When you want to program with Java on MacOS X, you install a JDK. The JDK is installed in a different path, and generally has no connection to the user-level JRE. That is, it is not reflected in the control panel, which is intended to control the user-level JRE.
Tools intended to work with the JDK will point to the JDK's JRE, and those that are intended to work with the user-level JRE will point to that.
I can't say exactly why they decided to have a full separation between the user Java and the developer Java. But I can offer a guess: Macs can be used by more than one user. Suppose one of those users is a developer and is making changes to the Java installation such as revoking and adding security keys in the keystore, changing the security policy files etc. I suppose Oracle doesn't want those changes in the development Java to affect all the other users of the Mac, who are not aware of the existence of the development environment and cannot make changes in it.
You update the JDK by downloading a full version from the Oracle web site. Mind you, every new JDK is installed in addition to the old JDK, but is set as the new default. If you want to remove the old JDK, you must do so manually, following the instructions on the Oracle site
If you use jdk-7uNN-macosx-x64.dmg via Java, it will install jdk in /Library/Java/JavaVirtualMachines/ and jre in /Library/Internet\ Plug-Ins/.
At the command line, running java points to /Library/Java/JavaVirtualMachines/jdk1.7.0_NN.jdk/Contents/Home/bin/java. On the other hand, Java Control Panel points to /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java, which will automatically update.
I have a bunch of webstart applications, which are programmed and tested under Java 1.6.0_11. For being sure that these applications run as intended, I start them using the javaws.exe of an installed JRE with version 1.6.0_11. This version is only used for starting these applications. The "standard" Java used on my System is always the newest version, in order to get all security updates (etc.).
With version 1.7.0_25 I am not able to call the javaws.exe from my 1.6.0_11 installation anymore. My applications simply do not start. It seems that the 1.7.0_25 webstart does not allow run applications which require an older version. So my problem is: How can I start my applications with the 1.6.0_11 java webstart?
My approach was to build a launcher application, which checks the required java version and calls the appropiate webstart via Runtime.exec(). But can I be sure that the called javaws.exe does not use any variables or resources of the installed 1.7.0_25 JRE? It is crucial to me to guarantee the flawless execution of these applications.
I have a Java desktop application for Mac, and we are porting Java along with the application. The issue, is that the Java we are using is strictly Java6 and not Java7 (Because Java7 does not have -d32 mode).
So I downloaded Java6 jdk from the apple developer site and have bundled it in the package. And it all works well. But when I try running on other Mac's, then it throws the following error:
/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin
$ ./java -version
dyld: Library not loaded: #rpath/libjli.jnilib
Referenced from: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/./java
Reason: image not found
Trace/BPT trap: 5
As per this, it tries searching for the respective directory at /Library/Java/JavaVirtualMachines/ and not in the folder I ported along. How can I solve this issue?
How should I port Java6 along with the application.
Secondly, the Java6 I have used is jdk as I could not find the Jre of Java6. It will be appreciated if someone can provide or share Jre6.
Does Apple licensing even allow their JRE to be redistributed with a third-party app?
I think you are making things harder than they need to be. If a user does not have Java 6 installed (possible in OS X 10.7 and 10.8), the Mac OS will automatically prompt the user to download and install it the first time a Java application tries to run. It will then automatically continue launching your app once it's installed.
Just make sure you are bundling your app appropriately for Java 6 (e.g., using the old Mac Jar Bundler app or manually creating an equivalent Info.plist) and not Java 7 (e.g., using the new Oracle appbundler.jar).
Problem: An application developed in Java does not launch when used with QTP having Java Addin enabled
When Java Addin is enable in QTP, the following environment variables is set
_JAVA_OPTIONS : -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes;C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
IBM_JAVA_OPTIONS : -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes;C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
When we try to launch the Java Client application for which we need to automate, it fails to launch
We tried removing the above environment variables but the QTP fails to recognize the objects in the Java Client application
I faced this issues. After much of tries, I recognize that change Environment Variable is not the perfect way to solve this.
Try somethings:
Update Oracle java to latest (8 as now), UFT 12.02 well supports jdk 1.8.
If Oracle jdk version <> UFT jdk version:
Open Java Control Panel > Java > View > User tab: Find & active both of them.
The last way, change System Variables:
Having 3 variables need to edit: _JAVA_OPTIONS,JAVA_TOOL_OPTIONS, IBM_JAVA_OPTIONS. Should add these values to user environment and should work on there, leave system environment as default or empty (i means "space"):
Empty all them then reinstall Oracle Java first.
Now, your java app will work well but UFT cannot recognize java applet.
Change 3 environment variables above back to QTP path (such as:
_JAVA_TOOLS = -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files
(x86)\HP\Unified Functional
Testing\bin\java_shared\classes";"C:\Program Files (x86)\HP\Unified
Functional Testing\bin\java_shared\classes\jasmine.jar"
JAVA_TOOL_OPTIONS = -agentlib:jvmhook
)
Restart all to get affect, QTP now work well with java.
I am trying to bundle java as a part of a java product that should be installed silently with a single click and are having some issues:
My installation has the following requirements:
Has no be silent and require no user input or action excpect a doubleclick on the installation file (no configuration and post install steps)
Has to setup java so that JAVA_HOME points to a Java SE installation with a server jvm
Is this at all possible to do this on a win32 system with sun java installers? I know that by default the jre does not contian a server jvm. But even when installing the jdk the public jre which is installed (and mapped to JAVA_HOME) does not contain a server jvm. In sun own README file (Sun README) they suggest copying the files:
jre\bin\server\
On Microsoft Windows platforms, the JDK includes both
the Java HotSpot(TM) Server VM and Java HotSpot Client VM.
However, the Java SE Runtime Environment for Microsoft Windows
platforms includes only the Java HotSpot Client VM. Those wishing
to use the Java HotSpot Server VM with the Java SE Runtime
Environment may copy the JDK's jre\bin\server folder to a
bin\server directory in the Java SE Runtime Environment.
But this solution is difficult to automate gracefully in a silent install. There has to be a better way to do this without repackaging the entire java distrubution. Has anyone encountered the same problem and come up with a more elegant solution?
For the past years, I manage Java like this: I download the installer, install it somewhere, package all files into a ZIP and then use that ZIP file to deploy Java anywhere. The installer will leave a lot of stuff in the registry and %WinDir%, etc. which you don't really need. This also allows me to move some files around (like the bin\server\jvm.dll or security related settings).
That way, I can even embed Java inside the application directory, independent of any already installed version of Java.
Just set JAVA_HOME in a small batch script before starting your application and you're good. You can use %~dp0 to make it completely position independent (%~dp0 expands to the path leading to the batch file).
Make your own installer.
I use inno setup compiler, works well for my purpose.
If you need the registry entries, you can export them, include them in the installer, include the files, and a little change here and there and you're done. Silent installer that configures things to the exact specifications you need.
It comes with an easy to use script wizard.
I mention a specific one because it's free. Ultimately, making your own installer is the solutions.