The new "Prefer Tabs" system setting in Mac OS X 11 (Big Sur) causes issues with Java applications. If the setting is set to "Always", or to "In full screen" and the application is running in full screen, JDialogs open as tabs and become unresponsive.
There is a way to set the "Prefer Tabs" setting on a per-application basis. For example, running
defaults write net.java.openjdk.cmd AppleWindowTabbingMode manual
in Terminal makes sure that NetBeans (and, seemingly, any application running on openjdk) works correctly.
Our application still supports Webstart on Mac. The above setting does not affect Webstart, so the problem still occurs there. I am not sure where the "net.java.openjdk.cmd" in the above command comes from, and where I can find the equivalent value for Webstart. It doesn't appear to be in Info.plist. Does anyone know what the value should be for Webstart (build 1.8.0_271-b09)? In general, how can I find the appropriate value for a specific application?
[Edit March 25 2021]
In an attempt to minimize burden on our users, my approach is to read the current setting using "defaults read X AppleWindowTabbingMode" from within our software. If it isn't set to manual, the software offers to run "defaults write X AppleWindowTabbingMode manual" and suggests that the user needs to restart the software afterwards.
In an attempt to get the bundle ID programmatically, I tried:
URL u = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().toURL();
URL canonicalHome = new URL(u.toString() + "jnlp");
appID = "com.oracle.jnlp-" + canonicalHome.hashCode();
but this doesn't seem to get me the right value. As far as I can tell, webstart actually uses something called JavaAppletPlugin which uses a 'java' executable, rather than 'javaws'. Any thoughts on how to programmatically get the right value?
Hope this is still relevant for you.
What you need is the bundle identifier for your app.
For openjdk this is:
<dict>
<key>CFBundleIdentifier</key>
<string>net.java.openjdk.cmd</string>
...
My guess is that a Webstart app is using javaws from the Oracle JVM.
In that case, the bundle identifier is a concatenation (from java source code):
this.bundleIdentifier = "com.oracle.jnlp-" + paramLaunchDesc.getCanonicalHome().hashCode();
You should try to create a shortcut for your app which should contain the bundle info in plist format. Get the identifier.
Then your Terminal command would become:
defaults write com.oracle.jnlp-<something> AppleWindowTabbingMode manual
Update
You might be able to find the identifier using the Java console. Enable it in the Java Control Panel which you can reach via System Preferences.
In the console, look for a log message like:
temp: bundleIdentifier is com.oracle.jnlp--<number>
Obviously it might differ for each installation :-( so you still have to find out exactly how java creates the identifier.
Related
I have a problem starting a commercial JavaWS application on IE11 on some computers at work. The application eventually starts but the user has to try several times before it works whick is very annoying.
We are currently using JRE 1.8.0_40 on Windows 7.
I have tried all possible things and in my research I've seen some references to Java Next-Generation Plugin and that It should be activated. When I open the Java Configuration I can't find this option. Why is that?
I have been reading this article where they mention Next-Generation Plugin and different ways of checking that it's activated.
If you read the article I linked thoroughly you find this way of checking/setting the option in the registry:
Go to Start/Run and type in “regedit.exe” in the Run dialog box. Click OK
Navigate to the following area in the registry (32-bit Java keys)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Plug-in\<version>
Find or create the registry key UseNewJavaPlugin (REG_DWORD)
Ensure this key is set to value 1
Close the registry and restart your browser sessions for the setting to take affect
I'm struggling with specifying which one of the many java installations on my Windows 7 machine would be used by the Internet Explorer for (1) running applete as well as (2) for Java web start.
For example, I am going to that Java-View tab in Java Control Panel, change the checkbox there, then make Java Console visible in the advanced tab and then find from the Console header that not always Java which is checked in the Java-View is actually executing applets in my browser.
In Java Control Panel Java-View along with the "User" tab, there is also a "System" tab.
One usually cannot change anything there, but what does that mean, and does it play any role?
In Java Control Panel Advanced tab you see "Default Java for browsers" checkboxes.
Why Microsoft Internet Explorer checkbox there is always checked and always grayed out?
Is this checkbox important or is it Java-View tab screen, which actually affects IE operations?
Also in jre/bin folder of each java instalation I see javacpl.exe file and can execute each of them, but only one of them, I guess, appears in actual computer Control Panel. How do you determine, which of them is really shown and can be executed through my computer Control Panel? Does it make sense to do anything with alternative javacpl.exe executables - will their execution affect my IE java-related functionality.
Basically, I'm in total confusion of how this mechanism works, and wwould very much appreciate if someone could give some clarification on at least some part of the above questions. And I'm mostly talking here about Java 1.6 and Java 1.7, I guess it would be even more difficult if we try to cover in this question also older java versions.
Thanks a lot for any help on this subject.
Regarding your first question
" which one of the many java installations on my Windows 7 machine would be used by the Internet Explorer for (1) running applete as well as (2) for Java web start."
This can be tested by making your applets contain Java 7 features like "Diamond Operator". Compile it by jdk 1.7 and then try to run in browser, if it runs then your browser is using 1.7 else 1.6.
Second ques -
"In Java Control Panel Java-View along with the "User" tab, there is also a "System" tab. One usually cannot change anything there, but what does that mean, and does it play any role?"
Answer- This is my guess that system tab will contain that option which is configured in JAVA_HOME environment variable OR it can that jdk which was installed more recently installed. Because offcourse default can be only one and not two.
Third question -
"In Java Control Panel Advanced tab you see "Default Java for browsers" checkboxes. Why Microsoft Internet Explorer checkbox there is always checked and always grayed out? Is this checkbox important or is it Java-View tab screen, which actually affects IE operations?"
Answer - The option is grayed out because the option is already chosen for you and you need not specify that.
Hope that helps.
Using Java 7 Update 5 always causes complications with Java apps (for me, notably MineCraft) because it attempts to use IPv6. Disabling IPv6 doesn't save this at all.
Every bit of information I found keeps saying to use a batch file to tell java to start the program with the "-Djava.net.preferIPv4Stack=true" parameter. This does fix my problem, but I would like to not start things with batch files.
Is there a way to set this for Java 7 globally? I've gone to the Java Control panel in the Java tab and set "-Djava.net.preferIPv4Stack=true" as a runtime parameter for Java 7 but it doesn't do anything.
Help me, you are my only hope. I would really like to stop using Java 6.
I have the same IPv6 issues with my development box at the office.
Go into your Environment Variables dialog from the Control Panel and create a new System variable called JAVA_OPTS and set the value to be -Djava.net.preferIPv4Stack=true.
After spending half a day searching and trying, I'm finally giving up.
I have a java application of which I create a runnable jar (to include any other libs and just have a single jar file). With launch4j and the runnable jar I'm making an executable "MyApp.exe".
The executable ist working fine, but I want to pin it to my windows 7 taskbar. For now, I just have the taskbar entry "Close window".
After reading and implementing the following solutions with JNA
Pinning a Java application to the Windows 7 taskbar
Using JNA to get/set application identifier
my Application displays it's "Application User Model ID" correctly in the gui (just for testing purpose).
BUT: my program is shown as "javaw.exe" in the Task Manager and I still can't pin it to the taskbar, even though I set the launch4j option "custom process name and XP style manifest".
Background information: I'm working with a windows 7 admin account and I don't want the app the require admin rights.
Anyways, if I start the app "as administrator" from the context menu and confirm the UAC message, I can now pin to the taskbar. BUT: even though I set the "Application User Model ID" properly, windows still wants to pin "javaw.exe", even though my program is now shown as "MyApp.exe" in the TaskManager.
I'm totaly confused. But I'm obviously not the only one, having these issues.
=> See the last comments to Gregory Pakosz answer in Using JNA to get/set application identifier
Final questions:
Gregory Pakosz way with JNA to set the "Application User Model ID" ( https://stackoverflow.com/a/1928830/1128689 ) is working for me. But still, windows recognizes my app as an instance of "javaw.exe". What else do I have to do?
Did maybe some windows or java update break something here?
Do I really have to run my app with elevated user rights? I really don't want to...
Are there some more options in launch4j which I have to set?
Do I have to use a manifest file in launch4j?
I got this working by creating an Exe from a runnable jar with the help of JSmooth
.Pinned it to the taskbar, and ran it with no problems.
Hope this helps
No problem with winrun4j either, which is newer and easier to use than Jsmooth
The root cause: javaw is registered as a Host process (in Windows' registry). The shortcut behaviour is probably caused by following (source: Application User Model IDs (AppUserModelIDs))
Application-Defined and System-Defined AppUserModelIDs
Some applications do not declare an explicit AppUserModelID. They are
optional. In that case, the system uses a series of heuristics to
assign an internal AppUserModelID.
[...]
if the process was launched through a shortcut that contains launch
arguments (usually the target content to host as the "application"),
the system can determine identity and the application can be pinned
and relaunched.
About the Host Process behaviour:
Registering an Application as a Host Process
An application can set
the IsHostApp registry entry to cause that executable's process to be
considered a host process by the taskbar. This affects its grouping
and default Jump List entries.
Are you looking for this, which I used in my application to show the running Java application on windows taskbar..
SystemTray systemTray = new SystemTray(composite, parent.getShell(), parent.getDisplay(), "My Application");
systemTray.makeSystemTray();
Is it possible to ask for elevated permissions from within a Java Application? Suggestions I've seen seem to all be centered around running an external executable or setting up a manifest to request privileges on launch. These aren't available to, for instance, applets. Is there any way to request elevation from a running application?
UAC is not something that a running process can request (doesn't matter what language you are running in). You have to request elevation at launch time.
The way that most windows apps handle this (and make it look like they are requesting elevation) is to spawn an extra copy of themselves, requesting elevation, and passing sufficient command line arguments to the new process so that the appropriate dialog can be displayed.
This is why UAC elevation in a dialog is always initiated by a button click that opens a new dialog.
So, in the Java world, you just have to do exactly what everyone else has to do: launch your app again, requesting elevation. There are several ways to launch elevated, the 'run as' verb probably being the easiest.
Looks like Sun will have to handle that kind of situation in the JRE since there's no other way of doing elevated actions than by running an external process.
If JRE supported it, JVM would probably have to run a separate, elevated process for the java code requesting the elevation.
For now however, only the manifest or running an external application are the only solutions available as far as I know.
The question is, what do you need elevation for?
You have to use an external (native) application to do this. This post provides source code and a great explanation:
UAC Prompt From Java
You could use jna and do a ShellExec. For lpOperation use "runas" (this is not documented). Since you likely need the full path to the (current) JavaVM which is stored in the registrylook at registry access, part of JNA.
Goto the folder where java is installed.
open the properties of javaw.exe / java.exe and set "run as administator" option true.