useranon
useranon

Reputation: 29514

Setting up Java in Ubuntu Lucid linux

i am trying to setup java in my Ubuntu LUcid linux .

I checked my machine whether i am having JAva already installed in my machine.

when i tried for java -version it showed me

aruna@aruna-desktop:/usr/bin$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-4ubuntu3) OpenJDK Server VM (build 16.0-b13, mixed mode)

how can i start my java coding .. Where can i save my java files..

EDIT

I tried an example as you said but while running it is showing me the error as

aruna@aruna-desktop:~/Desktop/java$ javac MyFirstJavaProg.java The program 'javac' can be found in the following packages: * openjdk-6-jdk * ecj * gcj-4.4-jdk * gcj-4.3 Try: sudo apt-get install

Upvotes: 0

Views: 549

Answers (7)

Denis Tulskiy
Denis Tulskiy

Reputation: 19177

sudo apt-get install default-jdk

This will install the Java Development Kit so that you can use javac, java compiler.

You can save your files anywhere. I'd recommend to use an IDE for a beginner. NetBeans will do fine:

sudo apt-get install netbeans.

Upvotes: 2

echox
echox

Reputation: 9860

So your Java is running :-)

For developing you will need the javac command which will translate your java source files into java bytecode which can be interpreted by your virtual maschine. It should be already installed on your system because java -v tells you, an Open Java Developer Kit is installed.

There is no special place for saving your files. I keep my source files in my home directory under ~/coding/java/projects/foo/

You can just create them with your favorite editor and compile them with javac.

For larger projects it makes sense to use some of the bigger IDEs which will support an VCS integration, some fancy code completion and simple navigation in the project beside lots of helpful plugins. I favor Eclipse, but there are enough others. Anyway you will maybe feel some kind of lost with these and for the basics IMHO its better to use a simple texteditor:

Thats for the tools, now for the learning :-) There are a lot of resources for learning java out there such as tutorials like:

How fast and what you need for your learning depends on the background you have and what you are trying to achive.

I personally like learning out of books a lot more than reading some tutorials on the net. A perfect introduction to java and object oriented programming is in my view

Upvotes: 2

giri
giri

Reputation: 27199

in ubuntu use synaptic manager and install JDK-6 with follwoing command

sudo apt-get install JDK-6

once you are done with installing JDK ,you can start programming.

Upvotes: 0

Jeroen Rosenberg
Jeroen Rosenberg

Reputation: 4682

You need to make sure that the jdk bin directory is on the path and then you can save and 'execute' your Java files anywhere you like.

My configuration in ~/.bashrc:

JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.20
export JAVA_HOME
export JDK_HOME=$JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

Upvotes: 0

Tassos Bassoukos
Tassos Bassoukos

Reputation: 16142

What you have is the Java Runtime Environment, which allows java programs to run. To write your own, you will need the Java Development Kit, a text editor and a command line. However, I would strongly suggest you use an Integrated Development Environment such as Eclipse, as it will make your life much easier.

Upvotes: 1

Jigar Joshi
Jigar Joshi

Reputation: 240900

The "best" way depends on you, here is better option:

read a book & tutorials
write some code
play around

As a kick start:

public class MyFirstJavaProg
{  
        public static void main(String args[])
        {
           System.out.println("Hello World!");
        }
}  

Save this into a file having name MyFirstJavaProg.java in any DIR say /home/user/one/
goto terminal
fire following commands from that dir

javac MyFirstJavaProg.java

this will compile your code and will generate a .class file
to run that fire

java MyFirstJavaProg  

Upvotes: 2

Related Questions