Java programming on BOSS GNU/Linux

August 18, 2010

Most people start learning Java on Windows by writing code on Notepad and them compiling it using the command line javac (compiler) and java(interpreter). This post tell you how to do something similar on BOSS GNU/Linux.

To install Java on BOSS GNU/Linux install sun-java6-jdk, BOSS 3.0 and above have sun-java6-jdk in the repositories so to install use Synaptic (to find out how to set up Synaptic on BOSS GNU/Linux click here).

Another option is to download the latest version of Oracle/ Sun JDK from here. You should download the .bin file, and then run it.  Be sure to set the environment variable JAVA_HOME. This can be done by appending the following to your .bashrc file:


The .bashrc file can be found in your home directory and can easily be edited by typing

$nano ~/.bashrc


$gedit ~/.bashrc

after editing ~/.bashrc, open a new terminal window(or in the same terminal type source .bashrc) and type the following command:

$echo $JAVA_HOME

this should display the path you just set. Next type

$java -version

This will show you the version of jdk you just setup.

Once you are done installing JDK, you can now type your Java code on Gedit(its like notepad on steriods) and then compile and run them using javac/java from the shell.

For details on using IDEs like Eclipse or NetBeans on BOSS GNU/Linux click here.

Using SCP to securely copy files over a network on BOSS GNU/Linux

August 18, 2010

SCP is used to Securely CoPy files over the network.

The syntax for copying a file from a remote computer onto your machine is:
scp -r <username@ipaddress:/path_to_file_at_source_computer> <destination>
the -r can be omitted if you are not copying directories.
Here username is the name of a user a/c on the computers between which the data is being transferred

To copy a file or directory from your machine to another machine on a network is:
scp -r <destination> <username@ipaddress:/path_to_file_at_source_computer>
Note that the -r option is only needed if its a directory thats being copied.

An example, I want to copy /home/boss/docs from a computer on the network with IP address onto my local machine(i.e., the machine iam using). I would use the following command:
scp -r boss@ .
Here boss is a user account on the computer I want to copy files from. On typing this command you’ll be prompted for the password to the account boss. Once thats done, you’ll see the files being copied from the source computer onto your current directory. The ‘.’ here us used to indicate the present working directory (pwd).You can replace it with any directory on your local computer that you can write into.