Running JAVA program in Linux Ubuntu
Information Technology December 16th, 2009Steps to run JAVA program in Ubuntu:
1. Go to Applications > Accessories > Terminal, to open terminal window.
2. Type the following in command line
gedit Add.java
3. Enter the code bellow in the editor.
/* Addition of two numbers – Add.java */
import java.io.*;
class Add
{
public static void main(String args[])
{
InputStreamReader ISR = new InputStreamReader(System.in);
BufferedReader BR = new BufferedReader(ISR);
int a = 0, b = 0;
try
{
System.out.print(”Enter the first number: “);
a = Integer.parseInt(BR.readLine());
System.out.print(”Enter the second number: “);
b = Integer.parseInt(BR.readLine());
}
catch(Exception e)
{
System.out.println(”Check the program.”);
}
System.out.println(”Addition of ” + a + ” + ” + b + ” is” + (a+b));
}
}
4. Save the file and close to return to terminal window.
5. Firstly compile the code using the following command
javac Add.java
That would produce an class file you may need to run the program.
7. Now run this executable using the following command
java Add
8. Output should show as follows
Enter the first number: 49
Enter the second number: 2
Addition of 49 + 2 is 51
Note: If java is not present in the system, download it through terminal window using command sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
December 18th, 2009 at 10:29 PM
[...] is the original post: Running JAVA program in Linux Ubuntu | BioGem.Org By admin | category: java | tags: binary-trees, concepts, database, java, linux, mp3-file, [...]
December 18th, 2009 at 10:48 PM
[...] post: Running JAVA program in Linux Ubuntu | BioGem.Org By admin | category: ubuntu linux | tags: builder, different-categorys, eclipse, flex, [...]
December 19th, 2009 at 8:41 AM
Dear Author http://www.biogem.org !
What excellent words
March 14th, 2010 at 1:32 PM
Hey man , thanks 4 posting but this article is hard to read in Chrome it is is overlapping.
March 31st, 2010 at 10:45 AM
Thanks for sharing this helpful info!
May 1st, 2010 at 11:41 PM
Must say its a impressive information for me. My Enlish is bad, I From Spain .I have Send this link to my friend also article
Running JAVA program in Linux Ubuntu | BioGem.Org
May 14th, 2010 at 1:18 PM
Amazing, truly excellent information. Your blog is really awesome. I bookmarked this and will come back once again.
Running JAVA program in Linux Ubuntu | BioGem.Org
May 24th, 2010 at 2:39 AM
hi all; i m using RHEL5 on my server machine and open suse 10 on my client machine.both system ping each other,firewall is off of my server…
May 29th, 2010 at 4:47 AM
nice to read this more bro
Running JAVA program in Linux Ubuntu http://www.torrente24.com
May 29th, 2010 at 9:42 PM
r u open source member?…