Java library system tutorial part 2

Java library tutorial part 2 presented on Apache Commons Lang library.

Now we'll use Apache Commons Lang library in the project. Java is multiplatform, but some things are by nature different in each platform. For example running an external command. In Windows one uses command cmd, but in Linux one uses bash.

In Apache Commons Lang library is a class SystemUtils with static field IS_OS_WINDOWS, which returns true, if you run this application on Windows and false otherwise.

In order to use the library in the project, you must add the library to Build Path. You can do that in several ways. I will show you the one most flexible. First we will create a user library in Eclipse and next we will associate this library with a project.

To create a user library click Window -> Preferences. Select Java -> Build Path -> User Libraries and create a new user library named apache-commons and add JAR commons-lang. Also attach source and javadoc.

Now we have to put this library to build path of a project, where we want to use it. Right click Project name -> Build Path -> Add Libraries and choose User Library, apache-commons.

Now you can use classes from this library. You can also see, that we have fully working Javadoc documentation and if you hold CONTROL key and click on some class or method, you can jump to source.

comments powered by Disqus


Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects: