In this tutorial, you learn how to write a Java fax program that uses the InterFAX web service. In the tutorial distribution, you can find a fully-working copy of the demo program you're about to build.
This section covers determining your Java version, creating a new project directory, adding the InterFax Java client library and other dependencies to your classpath, and registering for an InterFAX developer account.
Determining Java Version
Our sample uses the javac compiler on the command line. Type:
You should see output similar to:
If you're using an IDE, check that your compiler supports Java 1.5 or later.
Creating New Java Fax Project Directory
Create a new project directory with subdirectories for our Java fax source files, libraries, and compiled classes. For this example, use the following directory structure:
Adding InterFAX Java Client Library and Dependencies to Classpath
The InterFAX Java library is bundled as a JAR file called Interfax.jar. Put this JAR file in your lib directory along with Apache's AXIS library and its dependencies. Download the Java fax ZIP bundle, which includes the above directory structure and all of these JAR files. The JAR files included in this bundle are:
- Interfax.jar: The InterFAX Java client library
- log4j-1.2.8.jar: The Apache log4j logging framework
- axis.jar: Apache AXIS SOAP toolkit
- commons-discovery-0.2.jar: The Apache Commons Discovery library, required by Apache AXIS
- commons-logging-1.0.4.jar: The Apache Commons logging framework, required by Apache AXIS
- jaxrpc.jar: JAX-RPC API, required by Apache AXIS
- saaj.jar, JAX-RPC API: required by Apache AXIS
- wsdl4j-1.5.1.jar: WSDL API, required by Apache AXIS
Also included is a simple Log4J configuration file to enable login.
Registering for an InterFAX Developer Account
To register as a developer, you need to provide a designated fax number, at which you will receive test Java faxes that you send through InterFAX (or faxes sent using other APIs with InterFAX). With a developer account you can only fax to this one number.
Proceeding to Send a Java Fax
When you're done, proceed to send a fax.