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.
Related
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.
For a J2EE bean I am reusing code that was developed for a java swing application. JOptionPane.showMessageDialog() is unfortunately commonly used. Most occurences luckily in code sections that are not reused by the J2EE application, but in some cases lower levels of the code has instances of JOptionPane.showMessageDialog(). Obviously this it results in dialog boxes popping up on the server, which is what I want to avoid.
As a first step I'd like to somehow assure that no dialog boxes will ever occur on the server.
Someone suggested peeking in some event or paint queue (I do not recall which one):
That would be:
// old code: JOptionPane.showMessageDialog(msg);
if ( someEventQueue.size() == 0 ) // <== consider this pseudo-code
Log.log(msg); // I am running on a server. Tell the log.
else
JOptionPane.showMessageDialog(msg); // I have a user made of meat. Tell him!
I never really got that working. What would you do?
Make sure the server is started with
java -Djava.awt.headless=true
Most servers should be started that way by default. Then you can check:
boolean headless_check = GraphicsEnvironment.isHeadless();
More details on headless available here:
I just tested this with OpenJDK Runtime Environment (IcedTea 2.4.3) (Gentoo build 1.7.0_45-b31) on Linux, and I find that unset DISPLAY was also sufficient to make isHeadless() (and isHeadlessInstance()) return true.
So, this method doesn't just tell you whether AWT was forced to ignore the system's graphics capabilities, but rather whether your process has access to graphics capabilities at all.
Example:
The code is running on some box that has no display card (that's probably what you want to know) so you can always check the system property if for some reason you want to know whether headless mode was forced.
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.
I wrote the Swing program in Java 8. It, of course, does not run on machines which have Java 7 on them.
Is there a way to prompt the user, when he or she tries to run the .jar file, that Java 8 is required to run the program, preferably, by showing the dialog window with this prompt.
Create a new java 7 file that checks the users java version using System.getProperty("java.version") and then if it comes back as 8 then the java 7 file can start the java 8 file, if not it can send out a dialog box telling the user to upgrade.
If I remeber correctly, Launch4J could check for the correct JRE and would probably show some error message if the JRE could not be found. However, I do not know whether it works with Java 8.
This would also only work for Windows though.
I don't like the idea of a 2nd "launcher" jar/class that's written/compatible with a lower version of Java. That means that I have to keep this old version around indefinitely, which may be problematic since:
I need to know how old a version the launcher jar must be to cover all potential users.
I now need to support 2 versions of Java for my builds.
The old version may be insecure, and possibly EOL, with no hope of patches/fixes.
Java started embedding expiration dates in the version.
Consider launching your app via Java Web Start. This works on all platforms (I believe), and will handle the version checking for you.
Another alternative is to write a wrapper script (not written in Java) that launches your app. It could check for the presence and value of an environment variable (perhaps JAVA_HOME).
My Goal
I want to make it so that, on first run, my program will make its icon appear in the Windows 7 Taskbar. I know that the icon files are shortcuts in C:\Users\USERNAME\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar and mostly want to know this:
My Questions
How, in Java, can I create a shortcut file (.lnk)
Is it possible to even access that without admin privileges?
You should not need admin privileges but you do need to do this in context of the user whose taskbar is being changed.
Here's a library which does what you want: http://alumnus.caltech.edu/~jimmc/jshortcut/
There is a Java library providing the new Windows 7 features for Java. It's called J7Goodies by Strix Code. Applications using it can be properly pinned to the Windows 7 taskbar. You can also create your own jump lists, etc.