Unable to find any JVMs matching version “1.7” and Mac OS X Mavericks can’t see JAVA_HOME

Background: My .zlogin had a call to /usr/libexec/java_home 1.7 to set the JAVA_HOME to that of my Java 1.7 install, but it was an artifact of my former Mac OS X Lion configuration. I finally decided to “fix” the problem by installing JRE 7, but found my JAVA_HOME to be /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java, and then found […]

Java code to test if a string is a valid java identifier.

public class IdentifierTest { /** * @param args the command line arguments */ public static void main(String[] args) { for(String arg : args) { boolean start = true; boolean validIdentifier = true; arg.toCharArray() // commenter pointed out my error //for(byte b : arg.getBytes()) { for(char b : arg.toCharArray()) { if(start) { validIdentifier = validIdentifier && […]

Boxing of an Integer and conservation of space in Java

Apparently, boxing of an int literal initialization into an Integer class will result in two different objects being assigned the same space in memory if the number is 127 or smaller, but different spaces in memory if the number is 128 or larger. Take BoxTest.java: public class BoxTest { public static void main(String [] args) […]