Tuesday, February 7, 2012 7:56

Java Classpath

Tagged with:
Posted by on Monday, December 1, 2008, 22:54
This news item was posted in Java category and has 0 Comments so far.

Classpath

Being closely associated with the file system, the command-line Classpath syntax depends on the operating system. For example:

* on Linux, Mac OS X, and more generally on all Unix-like operating systems, the directory structure has a Unix syntax, and each filepath must be separated by a colon (“:”).

* On Windows, the directory structure has a Windows syntax, and each filepath must be separated by a semicolon (“;”).

This does not apply when the Classpath is defined in Manifest files, where each filepath must be separated by a space (” “), regardless of the operating system.

getResourceAsStream()

InputStream is = this.getClass().getResourceAsStream( “picture.gif” );

InputStream is = MyClass.class.getResourceAsStream( “stuff.ser” );

InputStream is = MyApp.class.getClassLoader().getResourceAsStream( “InWords.properties” );

The System.getProperty(”file.seperator”) can be replaced with: File.separator (a convenience field in the java.io.File class).

Leave a Reply

You can leave a response, or trackback from your own site.