Moshe Wagner recently released ZmanimPlasma for the Linux platform. This KDEPlasma desktop widget displays the Hebrew date and zmanim on a Linux desktop. The zmanim calculations use Moshe’s C++ portZmanim CLI wrapper that enables a C++ program to call the Java Zmanim API. There are no current plans to make this widget available on any other platform. It can be downloaded from the Luach project download page. Moshe has in the past used the Zmanim API for use in Linux and some cross-platform projects. These include the above-mentioned Zmanim CLI, and Zmanim GUI that uses the Zmanim CLI.
Updated on April 13, 2010 כ״ט בניסן תש״ע to reflect information from Moshe explaining that this was not a port.
Note: The code sample has been updated for the KosherJava Zmanim 3.x API, where GeoLocation takes a ZoneId instead of a TimeZone. The output shown below is from running it against version 3.1.0.
/**
* This program demonstrates how to calculate bearing to Yerushalayim
* using the kosherjava.com Zmanim API. Both the great circle and
* rhumb line methods are shown.
* To compile, ensure that the Zmanim jar is in your classpath.
*/
import com.kosherjava.zmanim.util.GeoLocation;
import java.time.ZoneId;
public class BearingToYerushalayim {
public static void main(String[] args) {
GeoLocation lakewood = new GeoLocation("Lakewood, NJ", 40.09596, -74.22213, 0, ZoneId.of("America/New_York"));
GeoLocation harHabayis = new GeoLocation("Har Habayis", 31.77805, 35.235149, 0, ZoneId.of("Asia/Jerusalem"));
double greatCircleInitialBearing = lakewood.getGeodesicInitialBearing(harHabayis);
double greatCircleDistance = lakewood.getGeodesicDistance(harHabayis);
double rhumbLineBearing = lakewood.getRhumbLineBearing(harHabayis);
double rhumbLineDistance = lakewood.getRhumbLineDistance(harHabayis);
System.out.println("Great circle initial bearing: " + greatCircleInitialBearing + " degrees");
System.out.println("Great circle distance: " + greatCircleDistance / 1000 + " km");
System.out.println("Rhumb line bearing: " + rhumbLineBearing + " degrees");
System.out.println("Rhumb line distance: " + rhumbLineDistance / 1000 + " km");
}
}
The output of the above code is:
Great circle initial bearing: 53.81786828306803 degrees
Great circle distance: 9244.617197329102 km
Rhumb line bearing: 95.37151951258849 degrees
Rhumb line distance: 9891.161030560183 km
Moshe Wagner, who wrote the Zmanim GUI, notified me in August that he created a command-line interface for zmanim using my Zmanim API. The technical approach of using reflection was similar to the way I used reflection in the Zmanim Clock Applet, but he took it to new heights. Sample use of accessing zmanim using his CLI is:
moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar
Usage: ZmanimCLI [options] [Time]
Options:
-d --date <yyyy/mm/dd> Set date. (Year first!)
-lat --latitude <latitude> Set location's latitude
-lon --longitude <longitude> Set location's longitude
-e --elevation <elevation> Set location's elevation; Positive only
-tz --timezone <timezone> Set location's TimeZone
Help:
-h --help Show this help
-stl --time-list Show common available times to display
-ftl --full-time-list Show all available times to display
-tzl --timezone-list Show available timezones
Example:
ZmanimCLI --latitude 31.7780 --longitude 35.235149 --elevation 600 --timezone Israel Sunrise
Will show the sunrise time today in Jerusalem
While your first reaction may be that it is interesting in a theoretical geeky way, but has no practical value, I will quote Moshe’s explanation as to why it is useful:
Why is this useful? Well, first of all it was a nice experiment. But mainly, you can now use Zmanim (although externally), via any language you want, no longer being tied to Java.
Months later, Moshe actually put this to practical use in his C++-based Luach project. This Luach (similar to the known Kaluach) uses the Qt framework, utilizing libhdate for the date stuff (something not offered by the Zmanim API at the time; the API has since added a full Jewish calendar), and the Zmanim API via the CLI for the zmanim calculations. While you would expect such an approach to be slow, using the Luach seemed almost instantaneous. I will post more about his Luach program (recently reviewed at KosherDev.com) at some point in the future.
This is a more technical variant of the “How do I install the Zmanim API Program?”, but coming from someone who already knows that it is a Java program that can’t be installed, but assumes that it can be run. The main method is the entry point to a Java program. Since this is a library/API and not a program, it does not have a main method. The code to generate zmanim is spelled out in the How to Use the Zmanim API page. Below is a full example of a very simple zmanim program that outputs sunrise, sof zman krias shema and sunset in Lakewood, NJ. Please ensure that the Zmanim jar (download) is in your classpath.
Note: The code sample has been updated for the KosherJava Zmanim 3.x API, where GeoLocation takes a ZoneId and zmanim are returned as an Instant (printed directly, an Instant shows UTC, so the sample formats it in the location’s time zone). The date is set to November 5, 2009, the date of the original output; remove the setLocalDate line to use the current date. The output shown below is from running it against version 3.1.0.
/**
* This program is a simple demonstration of the kosherjava.com Zmanim API.
* To compile, ensure that the Zmanim jar is in your classpath.
*/
import com.kosherjava.zmanim.ZmanimCalendar;
import com.kosherjava.zmanim.util.GeoLocation;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class SimpleZmanim {
public static void main(String[] args) {
String locationName = "Lakewood, NJ";
double latitude = 40.096; //latitude of Lakewood, NJ
double longitude = -74.222; //longitude of Lakewood, NJ
double elevation = 0; //optional elevation
//use a valid IANA time zone ID listed in java.time.ZoneId.getAvailableZoneIds()
ZoneId timeZone = ZoneId.of("America/New_York");
//create the location object
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
//create the ZmanimCalendar
ZmanimCalendar zc = new ZmanimCalendar(location);
//optionally set the date. If not set it will default to the current date
zc.setLocalDate(LocalDate.of(2009, 11, 5));
//zmanim are returned as an Instant; format them in the location's time zone
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z yyyy").withZone(timeZone);
System.out.println("Zmanim for " + locationName + " on " + zc.getLocalDate());
System.out.println("Sunrise: " + formatter.format(zc.getSunrise())); //output sunrise
System.out.println("Sof Zman Shema GRA: " + formatter.format(zc.getSofZmanShmaGRA())); //output Sof Zman Shema GRA
System.out.println("Sunset: " + formatter.format(zc.getSunset())); //output sunset
}
}
C:\path\to\code>javac SimpleZmanim.java
C:\path\to\code>java SimpleZmanim
Zmanim for Lakewood, NJ on 2009-11-05
Sunrise: Thu Nov 05 06:30:54 EST 2009
Sof Zman Shema GRA: Thu Nov 05 09:05:33 EST 2009
Sunset: Thu Nov 05 16:49:31 EST 2009
After numerous requests, the Zmanim Calendar Generator can now output a less extensive list of zmanim. While the “full” calendar option (the default) generates an Excel spreadsheet with 108 columns of zmanim, the “standard” output generates a spreadsheet with 15 columns containing the most commonly used zmanim. The exact list of what constitutes commonly used zmanim is likely to be tweaked over time. The spreadsheet was initially designed for developers as a sample of the various zmanim available in the API. Developers using the API, or a ported version of it, can compare their output to the spreadsheet for accuracy. Based on feedback, many people use it to generate shul calendars and wanted a less daunting list of zmanim.