« October 2007 | Main | February 2008 »

January 2008 Archives

January 3, 2008

JDev: Including a Class-Path In Your MANIFEST.MF

JAR File

Java Applications can and should be packaged in a Java Archive file (JAR file). This is basically a ZIP file with an additional META-INF directory which contains a file called MANIFEST.MF.

MANIFEST.MF

The MANIFEST.MF file contains a number of entries which I call tags. The most common ones are Manifest-Version, Main-Class, or Class-Path. You'll find Manifest-Version in every MANIFEST.MF file.

Main-Class

The Main-Class tag is useful for an application packaging with the main class defined, but not telling the user. To start the application you usually issue something like java -jar application.jar. One of the well known examples is java -jar oc4j.jar. To specify the Main-Class tag in your MANIFEST.MF you need to include the following line:
Main-Class: path.to.your.application.Main

Class-Path

The Class-Path tag is useful for specifying the list of the libraries application needs to successfully run. You can specify the class path like any other but use the blank character (' ') as the path separator. Ie. no colon (':')or semicolon (';') as for the Un*x/Linux or Win environments, respectively.
To specify the Class-Path tag in your MANIFEST.MF you need to include a line like the following:
Class-Path: lib/ojdbc14.jar lib/log4j.jar

Specifying MANIFEST.MF tags in JDev

JDeveloper offers you two choices to specify your MANIFEST.MF tags. But before you can do this, you have to create a Deployment Profile for your JDev project (New... > General > Deployment Profiles). Once you have this profile in your project, open the Deployment Profile Properties dialog window. Navigate to the Options entry for specifying the tags.

Include the MANIFEST.MF File

To make your specified tags available in your MANIFEST.MF, make sure to select the Include Manifest File (META-INF/MANIFEST.MF) checkbox.

Setting the Main-Class Tag

Since this is one of the most used tags, it got a primary location in the dialog and you get some help to find the right class. To complete the Main Class entry you can either enter the fully qualified class name or use the Browse button to find the right class.

ClassBrowser:
Picture 1: Class Browser window

Setting the Class-Path Tag

To specify the Class-Path tag in JDev you have to define a fragment file to be included in your MANIFEST.MF (or merged into the Manifest file). The fragment file could be in your source files and contains all the tags you'd like to specify.
Class-Path: 
  ../config/
  classes12.jar
  bc4jct.jar
  bc4jdomorcl.jar
  bc4jmt.jar
  commons-beanutils-bean-collections.jar
  commons-beanutils-core.jar
  commons-beanutils.jar
  commons-codec-1.3.jar
  commons-collections-3.1.jar
  commons-configuration-1.2.jar
  commons-digester.jar
  commons-lang-2.0.jar
  commons-logging.jar
  htbclnt.jar
  j2ee/home/oc4jclient.jar
For ease of work, I recommend to have a single line per library.

DeploymentProfile:
Picture 2: Deployment Profile window

Conclusion

This way we're free to specify every possible tag in the MANIFEST.MF. Although this is a workable solution, I wish setting the Class-Path would be much better supported by the Deployment Profile in JDev.

January 11, 2008

Blog Tagged

I've been blog-tagged by Eduardo Rodrigues.

Here are my eight things you may don't know about me:

  1. I live in the most thrilling city of the world. At least all residents any  many celebrities and some tourists think so. See yourself
  2. I'm married since 1990 and have two daughters.
  3. My wife and me went to the same high school, but never met there. A friend introduced us.
  4. I'm a hobby photographer and take pictures from my business travels with the cuddly toys my daughters press me to carry around.
  5. I'm heavily interested in typography and used to work for one of famous pre-press software companies, Berthold AG. This company went bankrupt in 1991 and many things like their beautiful fonts are really missed.
  6. To get my brains refueled, I do trick or stunt kiting. This is not a child game but brutally hard and requires high sophisticated concentration. On the other hands, my kids like it are keen to learn it, too. See this page for tricks I'm trying to achieve.
  7. For many people, including my daughters, I'm too curious and like know the details behind the things.
  8. In 1983 I assembled a racing bike from all the separate pieces I bought by mail order. At that time the frame color called Champagne was quite popular. This bike is still there but hardly usable as I haven't had the time to ride it for 15 years, now.
Here are my next ones: Didier Laurent, Clemens Utschig, Angus Myles, Stellan Aspenström, Jan Kettenis, Antony Reynolds, Steven Davelaar, Robbie Vanbrabant,

January 14, 2008

ADF In Action: Starting a New Blog Series

Where to Start?

When you want to start with ADF, you should consider the OTN JDeveloper Tutorial's (10.1.3.x) page. This gives you three tutorials and a number of additional Oracle By Example (OBE) how-to's. Although these tutorials are quite good, you're sometimes left out alone in the dark.

The Blog Series

Within the next blog entries, I'll start developing an ADF application from the ground up. I intend to build the same application in the current JDeveloper production version (10.1.3.3) and with the latest Technical Preview (TP3 at the moment) as well. Doing this includes covering the differences and the many options to chose from. So stay tuned.

January 26, 2008

ADF In Action: Setting Up the Gear

No fancy words this time, let's start.

Setting Up the Gear

OK, you've decided to learn to develop with ADF. Now is the time to get the minimal environment setup for you. Your toolbox should contain these tools:
  • JDeveloper - This is the primary tool for developing with ADF, none gives you better support. Get it from OTN.
  • Oracle XE Database - To makes things much, much easier, I prefer to use the Oracle XE database. This is a stripped down data base, which behaves a lot like a normal Oracle database, but uses less memory and allows only 4 GB data files. Get it from OTN.
  • On Linux you'll need to get a recent JDK 5 before running JDeveloper.
Once you've downloaded these tools. Install them.
Note: Oracle XE Installation
To speed up the boot time of my environments, I avoid the automatic XE startup. On Windows, I've changed the startup type for the services OracleServiceXE, OracleXETNSListener to Manual. On Linux, while running the post-installation task /etc/init.d/oracle-xe configure, you have to answer the question "Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:" with N.
Note: JDeveloper - Which version?
In this series I'll cover both JDeveloper 10.1.3.x and JDeveloper 11 Technical Preview 3 (TP 3). If you've to bet your project on it, start with JDeveloper 10.1.3.3. Migration options will be covered.

Installation Verification

Once everything is installed, we need to verify our setup.

Verifying XE

First start XE. On Windows and Linux you'll find an Oracle Database 10g Express Edition menu with a Start Database entry. After XE came up, you need to point your browser to the XE Homepage (http://127.0.0.1:8080/apex/). On the XE Homepage you can log in to the XE management console and can check the data base settings. Log in by entering sys and your password value provided during the installation. To finish this step click on the Logout link on the upper right corner.

Verifying JDeveloper

Now we're able to start JDeveloper. Depending on your JDeveloper download, you might be asked to supply the location of the JDK. On Windows, a window pops up and lets you browse to the java.exe file of your JDK. On Linux, you have to supply the home directory of the JDK installation (ie. /opt/java/jdk1.5.0_14 on my machine). Next, you'll see the JDeveloper splash screen which will be followed by the JDeveloper main window.
Note: JDeveloper 11g TP 3
The JDeveloper 11g TP3 release relies on the setting of the environment variable JDEV_USER_HOME for your user directory. This is by default $HOME/JDeveloper. On Windows this path includes white spaces (ie. c:\Documents and Settings\) which is not recommended for this release.

Verifying the Database Connection

The last step for today is the setup of the database connection in JDeveloper.

In 10.1.3.x

  1. Click on the Connections Navigator tab (upper left under the tool bar)
  2. Select Database
  3. Open the Context Menu and select New Database Connection...
  4. A four step wizard appears.
  5. Step 1 - Enter the Connection Name as sysXE
  6. Step 2 - Enter the Username as sys, the Password with your value, and the Role as SYDBA
  7. Step 3 - Enter the Hostname (localhost), the Port (1521), and the SID (XE)
  8. Step 4 - Test the connection by clicking on the Test Connection button. This should show a Success! message in the text area below.
  9. Click on the Finish button to close this wizard.
Now you can find your newly created database connection in the Database folder in the Connection Navigator.

In 11g TP 3

  1. Find the Resource Palette (if not visible chose View->Resource Palette)
  2. Once available find the New icon (a folder with a star on the upper right), click on it, a menu will appear.
  3. Select the New Connection sub-menu and select the Database menu item.
  4. In the Create Database Connection window fill in the blanks with the similar values as above. Connection Name sysXE, Username sys, Password your value, Role SYSDBA from the drop down, Host Name localhost, JDBC Port 1521, SID XE.
  5. Click on the Test Connection button and get the Success! message in the text area below the button.
  6. Before you close the window be sure to have the Create Connection In:IDE Connections (Resource Palette) radio button checked.
  7. Once everything is correct, click on the OK button to close the window and create the connection in the Resource Palette.

JDeveloper Differences So Far

With this little setup chapter you have already seen a major difference between the JDeveloper 10.1.3.x and 11g TP3 versions:
  • All connections are available as IDE-global in both versions.
  • 11g adds application-specific connections which can differ from the global settings
  • In 11g the Create Database Connection is now in one window only and much easier to use.

What's Next?

So far so good, we have the gear ready now and are prepared to continue. In the next part we'll use JDeveloper's Database Modeler to create the database model and schema for the application we'll develop in this series. Stay tuned.

About January 2008

This page contains all entries posted to Olaf Heimburger's Blog in January 2008. They are listed from oldest to newest.

October 2007 is the previous archive.

February 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle