Java Cheat Sheet

These are just a few entries for some java related incantations I use once or twice a year and then promptly forget.

Here are a few entries for some java related incantations I use once or twice a year and then promptly forget.

Older Versions of JDK

You too might be that guy who needs to run a project on some older version of the Java JDK. And you need to download that older version from somewhere. This archive page is a good source for these permissively licensed older versions.

Keytool

keytool -import -alias certAlias -file certFile.cer -keystore appCerts.storeCode language: Bash (bash)

The command above adds a cert “certFile.cer” to your keystore “appCerts.store”. You will be asked for the passphrase to appCerts.store. It is “changeit” if you have not changed it.

There are many ways to get the cert that you need. If you are just trying to get your server to call a secure website, on Windows you can extract the cert by clicking on the lock icon to the left of the URL bar, and following the steps, choosing “Base-64 encoded X.509 (.CER) as the format.

keytool -list -v -keystore keystoreName.jks | grep 'superCert-'Code language: Bash (bash)

List the aliases in a java keystore that start with a specific string.

keytool -list -v -keystore keystoreName.jks -alias "certAlias (mustUseQuotesIfAliasHasParens)"Code language: Bash (bash)

Print out info about a cert in a Java keystore.

keytool -delete -v -keystore ./path/to/file.jks -alias "alias name"Code language: Bash (bash)

Delete a cert from the keystore whose alias is “alias name”

Leave a Reply

Your email address will not be published. Required fields are marked *