Category Archives: Java

installing-java-jre

how to install java on ubuntu 11.10

If you’re using Ubuntu 11.10 (oneiric ocelot) beta1 (released on the first of this month), then first install some basic applications – if you want a list then  go here – I’ve already covered in a post – 10 things to do after fresh installation of Ubuntu 11.10. Anyway, in this post you will learn how to install Java Run time Environment (commonly called as JRE) on Ubuntu 11.10.

Java is one of the most popular programming languages , so probably you would be running a lot of software written in Java i.e Java Runtime environment (includes JVM – Java Virtual Machines – which translate java bytecodes into native – executable machine codes, and so JVM makes the Java programs platform independent) is required if you want to run applications/programs that is developed using Java. Additionally – if you want to run applet programs (java applets – small programs that runs in a browser) then you will have to install a plugin for that.

Installing Java Run-Time Environment(JRE) on Ubuntu 11.10

There are many options when it comes to Java Runtime Environment (sun-jdk-jre, openjdk-jre …) but we will go for openjdk-jre (one of the most popular JDK – which is an open source equivalent of proprietary jre, it works well on Linux based distro such as Ubuntu, and it’s pretty stable too). You can install it either from Ubuntu Software Center (search for java or open jdk, don’t forget to select the add-on plugin for applets while installing jre),

installing-java-jre
Installing Java - using Ubuntu Software Center

or open a terminal (Ctrl+Alt+T) and execute the command(s) –

OpenJDK 7 Java Runtime

 sudo apt-get install openjdk-7-jre

install Java for browser – firefox/chrome..

For running applets in your web browsers such as Mozilla Firefox or Google Chrome, you need to install icedtea plugin. Execute –

sudo apt-get install icedtea6-plugin

Have Fun!

JDK

how to install jdk on Ubuntu 11.04

Ubuntu (Latest Stable Version : Ubuntu 11.04 (Natty Narwhal) ) is one of the most popular Linux distribution on this planet while Java, the most popular programming language (Platform independent features makes Java Great! and superior to any other programming language, for building web and Desktop Applications). Due to a number of free( and of course they’re good) tools, compilers and other options Ubuntu has become the No. 1 choice, as a development platform, among the Java Developers (specifically young programmers).

If you are just a common user then you need only JRE (Java Runtime Environment) to execute java programs but If are going to write java programs or develop Apps then you need to install Java Development Kit (JDK, complete suite for Java Developers) along with some IDE like Eclipse or Netbeans (Not really necessary for absolute beginners). A lot of JDK’s are available, so if you have programmed before then choose the one you like, but on the other hand, try open-jdk-6, an open source Java Development Kit (contains Javac, an open source Java compiler and ). This post will explain – about installation procedure of Open-JDK on a freshly installed Ubuntu 11.04.

Java logo

Installing Java Development Kit (JDK) on Ubuntu 11.04

#1 : Open Synaptic Package Manager (and click on update button, it’s not necessary but it’s usually a good practice because in this way you will get the latest details about the packages), and search for ‘JDK’ or ‘open jdk’ in the quick search bar.

installing-jdk-ubuntu-11-04

#2 : Then select the package for installation ( by checking the small square box) and click on ok, if it asks for dependencies.

#3 : Now, click on ‘Apply’ button to begin the installation procedure…and wait for the installation to complete.

#4 : That’s All..to verify, open Terminal (CTRL+ALT+T) and type javac, you will see a lot info about the Java Compiler and …

Install JDK from command Line

Open Terminal and enter the following command(s), then enter your ubuntu login password followed by ‘y’ when prompted for yes/no.

sudo apt-get install openjdk-6-jdk
Eclipse - Best ide for java

best IDE (Integrated Development Environment) for Java

Java is one of the most popular programming languages mostly used in developing desktop applications, web applications and Enterprise/Complex business applications, probably due to it’s platform independency as .class files can be executed by JVM running on any operating system (GNU/Linux or Mac or Windows).

A lot of good open source frameworks (A framework is a set of libraries and programs/environment that allows developers to build real world applications very quickly in most efficient and productive way; Now a days,  MVC (Model View Controller) frameworks are very popular in web Apps development e.g struts, Play, Spring etc.) and IDE’s (Integrated Development Environment, e.g Eclipse, BlueJ, NetBeans, etc) are available for java programmers at $0 (free).

The problem is – a lot of options i.e if you are a beginner java programmer (Actually little more than a beginner because if you are an absolute beginner then better go with a simple source code editor like gedit or notepad++ or Emacs), then you may feel difficulty in selecting an IDE for coding. That’s why in this post I’ll explain about a free and open source IDE that I think is the best ide for Java programming. If you are not agree, then don’t forget to put your opinion here, through comment.

Best IDE for Java : Eclipse

Eclipse is one of the most popular IDE for java developers because it has a lot of sophisticated features with simple, cool and easy to use GUI(Graphical User Interface). Some people may not agree on the the point that ‘Eclipse is very simple to use’, they aren’t just wrong; the learning curve for the java programmers those who uses Eclipse is very steep in beginning but decreases continuously with time, although this trend is not not uncommon because Java itself follow this trend specifically if we use Java in web apps development (of course for server side processing because Java on client side (web browser), in the form of Applets has been a complete failure).

Eclipse - Best ide for java

Although eclipse has very flexible plugin architecture and it supports a lot of programming languages besides Java, such as C, C++, PHP, JavaScript etc, but it’s most popular as a Java IDE (and specifically optimized for JEE Applications) it’s platform independent (available for GNU/Linux, Windows and Mac).

Download Eclipse

There are some other IDE that you can try for Java e.g BlueJ (Interactive Java IDE specially built for students), Netbeans (another popular JAVA IDE, vs 7.0 released few weeks ago). You might feel more comfortable with any of these IDE’s because sometimes it depends on the type of project and sometimes it’s personal. Since it’s open source and free to use, I would recommend to try most of them.

Download BlueJ

Download NetBeans

string reverse in java

Java is one of the most popular programming language used today in developing real world applications (specifically in dynamic and sophisticated web Applications development). Java is strongly typed,object oriented, and multi-platform(even platform independent in general) programming languages. Learning curve with Java is very steep, in beginning ,but it’s very easy when you go ahead, so just relax and move on, solve some problems and write code, That’s the only way you can learn any programming language.

String is considered as an object data type in java. String is immutable (it means you can create and destroy strings but it’s content(characters) can’t can not be altered ) in Java. In this post you will learn, how to reverse a given string in Java. There are lot of ways to reverse a string in Java – the simplest and easy way is to use library methods/functions; but if you are a beginner then better try to do it in different ways because in that way you will learn more.

How to Reverse a String in Java without Using StringBuffer

Here is a program(save it as StringReverse.java and compiler=>execute) to get the reverse string – The code is very simple and comments are written, so no explanation is required,if you have any problem or question or you have any better solution then reply through comment.

import java.util.*;

public class StringReverse {
public static void main(String []args) {
//Get the string to be reversed
System.out.println("Enter the String to reverse");
Scanner scan=new Scanner(System.in);
String str=scan.nextLine();
// Test  System.out.println("The Given String was :"+str);
int stringLength = str.length();
// Test  System.out.println("The Length of the String is : "+stringLength);
char rawData[] =new char[50];
for(int k=0;k<50;k++)
rawData[k]=0;
// Using a for loop to iterate over the characters in string
for(int i=0,j=stringLength-1;i<stringLength;i++,j--) {
rawData[i]=str.charAt(j);
}
String reversedString=new String(rawData);
reversedString=reversedString.substring(0,stringLength);
System.out.println("The Reversed String is : "+reversedString);
//int sLength = reversedString.length();
//System.out.println("The Length of the String is : "+sLength);
}
}

If you are looking for the easiest method to reverse a string in Java, then use StringBuffer class and reverse() method, here is the code for that –

import java.util.*;
public class ReverseTheString {
public static void main(String []args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the String");
String str=sc.nextLine();
str = new StringBuffer(str).reverse().toString();
System.out.println("Reversed String : "+str);
}
}

how to install jre on ubuntu 10.10

java-logo

Java is an Object Oriented programming language whose syntax and features has highly influenced by C/C++.Java programs can also be embedded in web pages which requires Java Run Time Environment(JRE) in order to get executed.That’s why after the fresh installation of Ubuntu 10.10 Maverick Meerkat you would require JRE for surfing Internet without any lack of functionality;because a lot of websites now uses java Applets to do some client side computation.On Ubuntu open JDK(java Development Kit) is recommended.

Installing Java Run Time Environment in Ubuntu 10.10

To install JRE just go to Synaptic Package Manager and search for ‘jre’ and select the packages that says open jre/jdk.After marking the package click on Apply button to begin the installation procedure.Then wait until the installation is complete….that’s all you have installed JRE successfully on your Ubuntu 10.10 Maverick Meerkat.