Explain the JVM Directory Layout on Mac OSX Leopard - java

Here is the directory layout that was installed with Leopard. What is the "A" directory and why the "Current" directory in addition to the "CurrentJDK"?
It seems like you can easily switch the current JDK by move the CurrentJDK link, but then the contents under Current and A will be out of sync.
lrwxr-xr-x 1 root wheel 5 Jun 14 15:49 1.3 -> 1.3.1
drwxr-xr-x 3 root wheel 102 Jan 14 2008 1.3.1
lrwxr-xr-x 1 root wheel 5 Feb 21 2008 1.4 -> 1.4.2
lrwxr-xr-x 1 root wheel 3 Jun 14 15:49 1.4.1 -> 1.4
drwxr-xr-x 8 root wheel 272 Feb 21 2008 1.4.2
lrwxr-xr-x 1 root wheel 5 Feb 21 2008 1.5 -> 1.5.0
drwxr-xr-x 8 root wheel 272 Feb 21 2008 1.5.0
lrwxr-xr-x 1 root wheel 5 Jun 14 15:49 1.6 -> 1.6.0
drwxr-xr-x 8 root wheel 272 Jun 14 15:49 1.6.0
drwxr-xr-x 8 root wheel 272 Jun 14 15:49 A
lrwxr-xr-x 1 root wheel 1 Jun 14 15:49 Current -> A
lrwxr-xr-x 1 root wheel 3 Jun 14 15:49 CurrentJDK -> 1.5
steve-mbp /System/Library/Frameworks/JavaVM.framework/Versions $
and the contents of A
-rw-r--r-- 1 root wheel 1925 Feb 29 2008 CodeResources
drwxr-xr-x 34 root wheel 1156 Jun 14 15:49 Commands
drwxr-xr-x 3 root wheel 102 Mar 6 2008 Frameworks
drwxr-xr-x 16 root wheel 544 Jun 14 15:49 Headers
-rwxr-xr-x 1 root wheel 236080 Feb 29 2008 JavaVM
drwxr-xr-x 29 root wheel 986 Jun 14 15:49 Resources
steve-mbp /System/Library/Frameworks/JavaVM.framework/Versions/A $

The (A, Current symbolic-linked to A) is part of the structure of a Mac OS X framework, which JavaVM.framework is. This framework may have C or Objective-C code in it, in addition to the actual JVM installations. Thus it could potentially be linked against from some C or Objective-C code in addition to containing the JVM alongside that.
Note that you should not change the CurrentJDK link to point at anything but what it is set to by Mac OS X. Unlike on other platforms, the Java virtual machine is an operating system service on Mac OS X, and changing it in this way would put you in an unsupported (and potentially untested, unstable, etc.) configuration.

You should use the Java Preferences command to change the jvm version.
If you have spotlight on your Harddisk, you can just spotlight "Java Preferences"

If you want to revert to an older JVM (here, 1.5), you can put the following in your ~/.profile (or paste it into a specific Terminal window):
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/"
export PATH=$JAVA_HOME/bin/:$PATH

Related

JDK folder is missing in java version 1.8.0_362-b08 (for RHEL)

I got only jre folder for below java version but not the jdk folder.
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64
--------------------------------------------------------------------------------
[AU\bhrbr2#abcdefd08 ~]$ cd /usr/lib/jvm
[AU\bhrbr2#abcdefd08 jvm]$ ls -lrt
total 0
drwxr-xr-x 3 root root 16 Jan 27 17:04 java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64
lrwxrwxrwx 1 root root 51 Jan 27 17:04 jre-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64 -> java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64/jre
lrwxrwxrwx 1 root root 29 Jan 27 17:04 jre-openjdk -> /etc/alternatives/jre_openjdk
lrwxrwxrwx 1 root root 27 Jan 27 17:04 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx 1 root root 35 Jan 27 17:04 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
lrwxrwxrwx 1 root root 21 Jan 27 17:07 jre -> /etc/alternatives/jre
[AU\bhrbr2#abcdefd08 jvm]$ cd java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64
[AU\bhrbr2#abcdefd08 java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64]$ ls -lrt
total 0
drwxr-xr-x 4 root root 90 Jan 27 17:04 jre
--------------------------------------------------------------------------------
How can I get the JDK folder for this version?
I got the required jdk from OpenLogic site.
https://www.openlogic.com/openjdk-downloads?field_java_parent_version_target_id=416&field_operating_system_target_id=426&field_architecture_target_id=391&field_java_package_target_id=All
But I want to just install jdk alone using yum/rpm command line in RHEL for same version (as I already have the jre) under the same directory.
Thanks.

install4j support for code signing MacOS console launchers that load dyld libraries via System.loadLibrary

I have an issue with a MacOS folder DMG media file that I created with install4j 8.0.8. If I code sign the package, everything gets signed correctly including my *.dyld files that reside in a lib/ directory. Also, my GUI programs work fine and calls to System.loadLibrary() succeed and load the dyld files correctly. However, my command-line programs that call the same Java code as my GUI programs fail when they get to the System.loadLibrary() call with this message:
java.lang.UnsatisfiedLinkError: jhdf5 (Not found in java.library.path)
at java.base/java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1745)
at java.base/java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1697)
at java.base/java.lang.System.loadLibrary(System.java:591)
But, if I disable code signing when I build the media file for MacOS, which I do by passing disableSigning=true from Ant, both GUI and command-line programs work fine.
So possibly, I'm not understanding if I need to do something extra with the Java VM parameters when running a program from a console launcher versus a GUI launcher on MacOS (I'm running Big Sur). Or is it just not possible to run console launchers in a code signed media file where dyld files are loaded on demand? Maybe due to the fact that console launchers are implemented as scripts on MacOS. The install4j 8 documentation doesn't seem to mention this nuance that I can find.
The directory structure of the installed files looks like this:
Peters-MacBook-Pro-16:CoastWatch Utilities Signed phollema$ ll
total 4224
drwxr-xr-x 10 phollema admin 320 9 Apr 17:25 .
drwxrwxr-x 37 root admin 1184 9 Apr 17:24 ..
drwxr-xr-x 53 phollema admin 1696 9 Apr 17:25 .install4j
drwxr-xr-x 3 phollema admin 96 9 Apr 17:24 CoastWatch Utilities Uninstaller.app
drwxr-xr-x 25 phollema admin 800 9 Apr 18:50 bin
drwxr-xr-x 3 phollema admin 96 9 Apr 17:24 data
drwxr-xr-x 8 phollema admin 256 9 Apr 17:25 doc
drwxr-xr-x 3 phollema admin 96 9 Apr 17:24 extensions
drwxr-xr-x 4 phollema admin 128 9 Apr 17:25 lib
-rw-r--r-- 1 phollema admin 1608406 9 Apr 17:12 src.zip
Peters-MacBook-Pro-16:CoastWatch Utilities Signed phollema$ ll bin
total 624
drwxr-xr-x 25 phollema admin 800 9 Apr 18:50 .
drwxr-xr-x 10 phollema admin 320 9 Apr 17:25 ..
-rw-r--r--# 1 phollema admin 6148 9 Apr 18:50 .DS_Store
drwxr-xr-x 3 phollema admin 96 9 Apr 17:24 CoastWatch Data Analysis Tool.app
drwxr-xr-x 3 phollema admin 96 9 Apr 17:24 CoastWatch Master Tool.app
drwxr-xr-x 3 phollema admin 96 9 Apr 17:24 CoastWatch Status Tool.app
-rwxr-xr-x 1 phollema admin 14801 9 Apr 17:12 cwangles
-rwxr-xr-x 1 phollema admin 14803 9 Apr 17:12 cwautonav
-rwxr-xr-x 1 phollema admin 14829 9 Apr 17:12 cwcomposite
-rwxr-xr-x 1 phollema admin 14827 9 Apr 17:12 cwcoverage
-rwxr-xr-x 1 phollema admin 14805 9 Apr 17:12 cwdownload
-rwxr-xr-x 1 phollema admin 14801 9 Apr 17:12 cwexport
-rwxr-xr-x 1 phollema admin 14827 9 Apr 17:12 cwgraphics
-rwxr-xr-x 1 phollema admin 14789 9 Apr 17:12 cwgscript
-rwxr-xr-x 1 phollema admin 14823 9 Apr 17:12 cwimport
-rwxr-xr-x 1 phollema admin 14797 9 Apr 17:12 cwinfo
-rwxr-xr-x 1 phollema admin 14819 9 Apr 17:12 cwmath
-rwxr-xr-x 1 phollema admin 14805 9 Apr 17:12 cwnavigate
-rwxr-xr-x 1 phollema admin 14829 9 Apr 17:12 cwregister
-rwxr-xr-x 1 phollema admin 14831 9 Apr 17:12 cwregister2
-rwxr-xr-x 1 phollema admin 14823 9 Apr 17:12 cwrender
-rwxr-xr-x 1 phollema admin 14801 9 Apr 17:12 cwsample
-rwxr-xr-x 1 phollema admin 14841 9 Apr 17:12 cwscript
-rwxr-xr-x 1 phollema admin 14799 9 Apr 17:12 cwstats
-rwxr-xr-x 1 phollema admin 14763 9 Apr 17:12 hdatt
Peters-MacBook-Pro-16:CoastWatch Utilities Signed phollema$ ll lib/native/macosx_x86_64/
total 12544
drwxr-xr-x 4 phollema admin 128 9 Apr 17:25 .
drwxr-xr-x 3 phollema admin 96 9 Apr 17:25 ..
-rw-r--r-- 1 phollema admin 1748128 9 Apr 17:12 libjhdf.dylib
-rw-r--r-- 1 phollema admin 3536000 9 Apr 17:12 libjhdf5.dylib
Also, the console launcher scripts contain a line that adds to the DYLD_LIBRARY_PATH like this:
DYLD_LIBRARY_PATH="$app_home/lib/native/macosx_x86_64:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
All of this works if I don't sign the media file, and the console launcher scripts are identical.
Notarization requires enabling the "Hardened runtime" which prevents the use of DYLD_LIBRARY_PATH unless a specific entitlement is set for the launcher executable. As of install4j 9.0.1, entitlements can only be set for GUI launchers and not for the java executable of a bundled JRE which is what would be needed for command line launchers.
However, setting -Djava.library.path is a good solution and preferable to setting entitlements.

Updating java 6 cacerts with those from java 8

Rackspace replaced an outdated certificate, ive followed their instructions using keytool to update the cacerts for java 6 with no success (keytool).
What did work was just replacing the cacerts file from java 6 with one from java 8.
Is this "OK" to do? i assume formats between the two are the same and they are simply updated between version.
Apologies in advance if this is a stupid question
I initially did the same thing, and then symlinked to the java 8 file. But my problem was that the java 6 installation on macOs High Sierra (10.13.x).
# store path to java 6 home
tmp $ j6Security=$(/usr/libexec/java_home -v '1.6*')/lib/security;
# show pre-update state
tmp $ ls -la "$j6Security"
total 16
drwxr-xr-x 10 root wheel 320 Jan 20 19:39 .
drwxr-xr-x 41 root wheel 1312 Jan 20 19:39 ..
-rw-r--r-- 1 root wheel 2469 Jul 14 2015 US_export_policy.jar
lrwxr-xr-x 1 root wheel 79 Jan 20 19:39 blacklist -> /System/Library/Java/Support/Deploy.bundle/Contents/Home/lib/security/blacklist
lrwxr-xr-x 1 root wheel 81 Jan 20 19:39 cacerts -> /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security/cacerts
-rw-r--r-- 1 root wheel 3443 Jul 14 2015 java.policy
-rw-r--r-- 1 root wheel 13458 Jul 14 2015 java.security
-rw-r--r-- 1 root wheel 2486 Jul 14 2015 local_policy.jar
-rw-r--r-- 1 root wheel 347 Jul 14 2015 sunpkcs11-macosx.cfg
lrwxr-xr-x 1 root wheel 87 Jan 20 19:39 trusted.libraries -> /System/Library/Java/Support/Deploy.bundle/Contents/Home/lib/security/trusted.libraries
# store path to current (i.e., switcher) home
tmp $ jXSecurity=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security;
# replace (broken) j6 files with symlink to current files
tmp $ for file in blacklist cacerts trusted.libraries; do src="${jXSecurity}/${file}" tgt="${j6Security}/${file}"; test -f $tgt && sudo rm $tgt; sudo ln -s "$src" "$tgt"; done
# show post-update state
tmp $ ls -la "$j6Security"
total 16
drwxr-xr-x 10 root wheel 320 Jan 20 20:33 .
drwxr-xr-x 41 root wheel 1312 Jan 20 19:39 ..
-rw-r--r-- 1 root wheel 2469 Jul 14 2015 US_export_policy.jar
lrwxr-xr-x 1 root wheel 87 Jan 20 20:33 blacklist -> /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/blacklist
lrwxr-xr-x 1 root wheel 85 Jan 20 20:33 cacerts -> /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/cacerts
-rw-r--r-- 1 root wheel 3443 Jul 14 2015 java.policy
-rw-r--r-- 1 root wheel 13458 Jul 14 2015 java.security
-rw-r--r-- 1 root wheel 2486 Jul 14 2015 local_policy.jar
-rw-r--r-- 1 root wheel 347 Jul 14 2015 sunpkcs11-macosx.cfg
lrwxr-xr-x 1 root wheel 95 Jan 20 20:33 trusted.libraries -> /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/trusted.libraries
If I wanted to pin j8, I would replace jXSecurity=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/trusted.libraries with j8Security=$(/usr/libexec/java_home -v '1.8*'). Both this and copying the files (that I've symlinked in this example) worked fine.
(In my case the installed symlinks (in the "pre-update" output) pointed to nonexistent files. My maven downloads were failing with "peer not authenticated". After applying these changes to my jdk6 installation everything began working again.)

Permanently remove Pivotal tc from STS

I am using STS since a long time and the only feature annoys me is, it creates a new Pivotal tc Server instance in every workspace created and I never use Pivotal tc.
Can anyone tell me how to completely remove Pivotal tc Server from STS installation?
I have tried to update the artifacts.xml file, bundles.info (equinox) and bluntly deleting the features for Pivotal tc but I've never got clean result.
Once you unzipped the distribution it should have a folder with tc-server in it. Simply delete that entire folder and STS will no longer try and create a tc-server install in your workspace.
For example in my installation it looks like this:
$ ls -la sts-bundle/
total 20
drwxrwxr-x 5 kdvolder kdvolder 4096 Oct 12 05:47 .
drwxr-xr-x 23 kdvolder kdvolder 4096 Nov 6 14:43 ..
drwxr-xr-x 2 kdvolder kdvolder 4096 Oct 11 04:03 legal
drwxr-xr-x 11 kdvolder kdvolder 4096 Oct 13 07:56 pivotal-tc-server-developer-3.2.8.RELEASE
drwxr-xr-x 9 kdvolder kdvolder 4096 Nov 3 15:41 sts-3.9.1.RELEASE
So simply delete the folder pivotal-tc-server-developer-3.2.8.RELEASE.

Problems importing JAI in Eclipse

I'm trying to use the following import in Eclipse running on Mac OS X 10.6:
import javax.media.jai.JAI;
Unfortunately, this doesn't work, instead I get the following message:
"Access restriction: The type JAI is not accessible due to restriction on required library /System/Library/Java/Extensions/jai_core.jar"
How can this be resolved? I want to use JAI.create("fileload", "filename");
The file permissions in the folder Extensions:
$ ls -l
total 20536
-rwxrwxr-x 1 root wheel 6470 6 Jan 19:20 AppleScriptEngine.jar
-rwxrwxr-x 1 root wheel 12838 23 Apr 18:16 MRJToolkit.jar
-rwxrwxr-x 1 root wheel 938700 3 Mar 01:41 QTJava.zip
-rwxrwxr-x 1 root wheel 17786 11 Feb 13:49 dns_sd.jar
-rwxrwxr-x 1 root wheel 1223487 21 Jul 2009 j3daudio.jar
-rwxrwxr-x 1 root wheel 1157342 21 Jul 2009 j3dcore.jar
-rwxrwxr-x 1 root wheel 685292 21 Jul 2009 j3dutils.jar
-rwxrwxr-x 1 root wheel 275486 18 May 2009 jai_codec.jar
-rwxrwxr-x 1 root wheel 1544537 18 May 2009 jai_core.jar
-rwxrwxr-x 1 root wheel 106688 6 Jan 19:20 libAppleScriptEngine.jnilib
-rwxrwxr-x 1 root wheel 427632 21 Jul 2009 libJ3D.jnilib
-rwxrwxr-x 1 root wheel 733280 21 Jul 2009 libJ3DAudio.jnilib
-rwxrwxr-x 1 root wheel 50880 21 Jul 2009 libJ3DUtils.jnilib
-rwxrwxr-x 1 root wheel 1004544 3 Mar 01:44 libQTJNative.jnilib
-rwxrwxr-x 1 root wheel 50352 23 Dec 10:25 libShark.jnilib
-rwxrwxr-x 1 root wheel 9959424 18 May 2009 libmlib_jai.jnilib
-rwxrwxr-x 1 root wheel 41239 18 May 2009 mlibwrapper_jai.jar
-rwxrwxr-x 1 root wheel 127628 21 Jul 2009 vecmath.jar
A quick fix can be found here: http://lkamal.blogspot.com/2008/09/eclipse-access-restriction-on-library.html (However, it's more of a work-around...)
You might check file's the permissions. Here's what 10.5 looks like:
$ ls -l /System/Library/Java/Extensions/jai_core.jar
-rw-r--r-- 1 root wheel 1893836 May 31 2008 /System/Library/Java/Extensions/jai_core.jar
Fixed my issue with JAI by removing the JRE System Library from the build path and then re-adding it. This fix is based on the solution provided here.

Categories

Resources