How to install the gcj Java compiler on Debian 7.0 and compile a simple program.

Posted: August 10, 2013. At: 12:25 AM. This was 4 years ago. Post ID: 6102
Page permalink:

Now, we must convince Congress to stop the FCC. Can you display an alert?

This is how to compile a Java source file on Linux with gcj.

homer@neo:~/Documents$ gcj --main=HelloWorld

This is the source file that I am working with.

 * My first Java program.
import java.util.Date;
public class HelloWorld {
	public static void main(String[] args) {
		System.out.printf("\"Hello, World\"\n");
		Date date = new Date();
		System.out.println("The date is: " + date.toString() + ".");

And after I have compiled the program, I can run it by typing ./a.out and I will see the output.

homer@neo:~/Documents$ ./a.out 
"Hello, World"
The date is: Sat Aug 10 00:16:15 AEST 2013.

And this is how to install the gcj Java compiler on Debian 7.0.

sudo apt-get install gcj-4.6-jre
homer@neo:~$ sudo apt-get install gcj-4.6-jre
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gcj-4.6-jre is already the newest version.
The following packages were automatically installed and are no longer required:
  libossp-uuid16 libpq5 postgresql-client-common postgresql-common timelimit
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 118 not upgraded.

No comments have been made. Use this form to start the conversation :)

Leave a Reply