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 5 years ago. Post ID: 6102
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

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

[email protected]:~/Documents$ gcj --main=HelloWorld HelloWorld.java

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
[email protected]:~$ 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