For a list of pointers to packages of the BSD Port for DragonFly BSD, FreeBSD, Mac OS X, NetBSD and OpenBSD, please see the BSD porting Project's wiki page. If you want to develop Java programs then install the java-1.6.0-openjdk-devel package. The java-1.6.0-openjdk package contains just the Java Runtime Environment. If your Mac is using an earlier version of any Mac operating system, you should install the latest Apple software updates, which can include important security updates and updates for the apps that are installed.
As updates that change the macOS version number become available, this article is updated to show the latest version of that macOS. Java version '' Java(TM) SE Runtime Environment (build -b11) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode) but in Oracle's documentation and list of downloads I see references to versions that are much higher, notably 9 or even 10.