Archive

Archive for March, 2008

How to Install JPCap on Linux

March 29th, 2008 jesse No comments

gnome-pdf.png

In this tutorial I will describe how to install JPCap from source code on Linux (Ubunty 7.10 or Debian 4.0).

JPCap is an open-source Java library released under the GNU LGPL and designed to enable the capturing and sending network packets in Java. JPCap is developed by Keita Fujii and the University of California and Irvine.

The JPCap home page is  http://netresearch.ics.uci.edu/kfujii/jpcap/doc/

JPCap is a Java Native Library Implementation (JNI) of the popular libpcap library and should therefor work on any OS which supports libpcap. libpcap is a user-level packet capture library that provides a common, system-independent API for low-level network monitoring. libpcap is also open-source software developed and maintained by TCPDump.org.

We will use JPCap and libpcap on the Linux operating system but the both libraries work on Microsoft Windows (WinPcap), Linux, FreeBSD, and Mac OS X.

JPCap supports the following types of network data:
Layer 2:    Ethernet Datagrams
Layer 3:    IPv4 & Ipv6     ARP/RARP
TCP, UDP and ICMPv4.

JPCap recognizes the packet types enumerated above but can capture any type of network traffic as a raw packet (i.e., as an instance of the Packet class) which contains the Packet’s whole data. This feature allows Java applications to analyze any packet type.

Step 1:    Preparing the System

Following are instructions to install JPCap on a fresh installation of Ubuntu 7.10 of Debian 4.0.

Install the necessary development software packages to create a usable development environment:

Install the GNU compiler and basic libraries
% sudo apt-get install build-essential

Install the linux pcap library
% sudo apt-get install libpcap0.8

Install the Java SDK from Sun
% sudo apt-get install sun-java6-sdk

Download the latest JPCap source and extract it into your working directory

http://netresearch.ics.uci.edu/kfujii/jpcap/

You can also find version 0.7 here: JPCap 0.7

Step 2:    Building & Installing the JPCap JNI library

In a terminal window, navigate to the [jpcap]/src/c directory. For example:
~/jpcap-0.7/src/c

[IMPORTANT] Edit the JAVA_DIR Makefile entry to point to your version of jni.h
You can find it quickly with the following command:
$ find /usr -name jni.h
/usr/lib/jvm/java-6-sun-1.6.0.03/include/jni.h

The Makefile should then read
JAVA_DIR = /usr/lib/jvm/java-6-sun-1.6.0.03

In the terminal window under the [jpcap]/src/c directory type make to create the shared library
$ make
This will create the file ‘libjpcap.so’.

Copy ‘libjpcap.so’ your system’s Java JNI library directory
‘[Java-dir]/jre/lib/<arch>’ where <arch> is either ‘i386′ or ‘sparc’.
For my installation, this was /usr/lib/jvm/java-6-sun/jre/lib/i386
Another option is to copy the library to the directory where your application is located.

Step 3:    Building and Installing the JPCap JAR file

In a terminal window, nagivate to the [jpcap]/src/java directory. For example:
~/jpcap-0.7/src/java
There should be one subdirectory named ‘jpcap’

Compile all of the .java files in the ‘jpcap’ and ‘jpcap/packet’ directories.
$ find . -name “*.java” -exec javac {} \;

You may see the following error for IPPacket.java – ignore it.
“Note: ./jpcap/packet/IPPacket.java uses unchecked or unsafe operations.”

Create the JAR file
jar -cf jpcap.jar jpcap

Confirm the contents of your JAR file with the following command:
jar -tvf jpcap.jar

Copy the new jpcap.jar file to your Java extentions directory
$ cp jpcap.jar ‘[Java-dir]/jre/lib/ext/
For my installation, this was /usr/lib/jvm/java-6-sun/jre/lib/ext
Another option is to copy the JAR file to your application’s directory and add it to your CLASSPATH.

You are now ready to begin using the JPCAP Java Native Interface Library.

Categories: Java Development, Linux Tags:

Java Notes about Classloader Errors

March 22nd, 2008 jesse No comments

Having Problems with the Java ClassLoader?

When you wrap your code into a package you must run the program differently from the command line. Specifically, you must always tell Java where to find the main method. When you use a package, main is wrapped inside. e.g.

package foo;
public class helloworld { ...
public static void main ....

For example, the exact same helloworld.java code, without a package is run as follows:

% java helloworld

With a package you must type:

% java foo.helloworld

If you typed java helloworld when using a package in your code you’ll see the following type of error

Exception in thread "main" java.lang.NoClassDefFoundError: helloworld (wrong name: foo/helloworld)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Categories: Java Development Tags:

Report: Satellite Market Growing but US Role Shrinking

March 1st, 2008 jesse No comments

Forecast International recently released their Space Systems Forecast – Satellites & Spacecraft report.

forecast-intl

Summary:

  • The communications satellite sector is doing well around the world.
  • Manufacturing and services may migrate from US dominated to overseas.
  • The global communications satellite market is expected to generate deliveries of nearly 300 satellites during the next 10 years.
  • While demand for satellite services is growing, increasing satellite size, power and service life has decreased new spacecraft orders and demand.
  • Roughly 218 geostationary and medium-Earth orbit satellites will be delivered during the next 10 years and valued at nearly $26 billion.
  • The low-Earth orbiting market should see about 70 new satellites orders worth about $927 million, mostly fleet replacement within and Orbcomm.
  • The U.S. share of the satellite manufacturing market has declined by almost 30 percent over the past three years (2004-2007).
  • In 2004, 75 percent of commercial communications satellite orders went to three U.S. companies, while only three went to non-U.S. builders. That number dropped to 63 percent in 2005 and 40 percent last year.

My Comments:

The industry’s historical average is about 35 commercial launches per year.

The raw numbers from this report are less impressive but essentially mean that EADS and Alcatel are becoming more competitive and winning orders from non-US satellite operators (primarily national operators like Turksat, Arabsat, etc.).

This development is a result of earlier operator consolidation in the US (Intelsat + PanAmSat, SES + New Skies) and should continue to propagate consolidation through the US delivery chain.

I expect to see interesting spacecraft and launch tie-ups coming from Lockheed, Loral, Orbital, Boeing and Sea Launch in the near future.

References:

Space is not only the “Final Frontier,” but also a vitally important aerospace and defense asset. Prices in the commercial satellite industry are poised to rebound, keeping competition fierce and returning many firms to profitability.

Categories: Satellite Business Tags:

Removing .DS_Store on Network Share Drives

March 1st, 2008 jesse No comments

Mac OS XOne annoyance about OSX is that is leaves behind a .DS_Store file on network share drives (Samba, etc.) This file contains folder-specific display preferences for the way those files and folders should be viewed.

How to get rid of them?

Apple has as article How to prevent .DS_Store file creation over network connections on exactly how to do this but to summarize, from a terminal, type the following:

% defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Press return and reboot your mac.

Since this command turns off this behavior on a per user basis, it has to be repeated for every account on the computer that access a remote file share.

Categories: Uncategorized Tags: