Category Archives: java programming

Difference between two dates in java

The easiest way to get the difference between two dates without using a third library is using the TimeUnitclass. Be careful, the result is rounded. I use this code mostly when I need to render a human readable interval. Notice … Continue reading

Posted in java programming | Tagged , , | Leave a comment

A web server embedded in your java application with Jetty

The more I work with Jetty, the more I love it. It’s really amazing to have a web server in your hand that you can modify at will. I like being able to include a light web server in my … Continue reading

Posted in java programming, library | Tagged , , , | 3 Comments

Validate XML schema with Commons Configuration in Java

If you’re looking for a way to generate an XSD file, you should check this link. There is many ways to change the behavior of a program, one of them is to use a configuration file. If you have many … Continue reading

Posted in java programming, library | Tagged , , , | Leave a comment

Simple SFTP example in Java with Jsch

I use Jsch lib to connect in ssh to a remote sftp server. The program connects to the server, and then count the number of files in the directory and then displays their contents.

Posted in java programming, library | Tagged , , , | 7 Comments

Wake on Lan with Java

My house has more computers than people living in. Most of these machines are sleeping. Sometime, I need to retrieve one or more files from one of them. It will be troublesome if I had to walk around to boot … Continue reading

Posted in java programming | Tagged , , | Leave a comment

Pass through proxy from your java program

How to pass through your company proxy to access http resources on the net ? This simple code has been tested on a NTLM Authorization Proxy Server, the kind of proxy you find when your company work with MS OS. … Continue reading

Posted in java programming | Tagged , , | Leave a comment

Connect to ssh server with java

I often have to write a program to connect to a ssh server and manage tasks. Here is how I do. First you need to download the library. You will find it here, it’s called JSch. This simple program will … Continue reading

Posted in java programming | Tagged , , , | 1 Comment

Jetty embedded serving jsp

If you’re looking for a way to serve jsp easily, you’re at the good place. Today, to serve jsp, most of the time, you will need a web server and a servlet container (like Apache Tomcat). But if you don’t … Continue reading

Posted in java programming | Tagged , , | 2 Comments

How to connect to oracle database via jdbc

Add the jdbc jar to your project, for a recent oracle database, you can use this link. You have to sign up with oracle. Load the jdbc driver. With the DriverManager class, get a connection. Don’t forget to close it … Continue reading

Posted in java programming | Tagged , | Leave a comment

Installing jdk7 on a linux box – The easy way

If you want to install the oracle jdk7 and you don’t have root privileges, don’t worry, you don’t need it. Download the zip file from the oracle website. On your linux box, unzip the tar : tar -xvf <filename> on the … Continue reading

Posted in java programming | Tagged , | Leave a comment