Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-09-2007, 04:53 AM   #1
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Rep: Reputation: 30
using JAVA and Netbeans in Fedora core6

Hi jay73

i have created in the /home/user/Desktop
i have reinstalled fedora core 6 and i have set all the prerequisites for the jdk and tomcat..i have installed netbeans
[environment variables]

for the first time when i have run javac,java they worked ....but now not working

i am getting the following error

[root@localhost Desktop]# vi
[root@localhost Desktop]# javac
[root@localhost Desktop]# java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello

the content in the file is as follows

[root@localhost Desktop]$ cat
public class Hello{

public static void main (String [] args){



edited lines in /etc/profile are as follows
export JAVA_HOME=/opt/jdk1.6.0
export CATALINA_HOME=/opt/netbeans-5.5/enterprise3/apache-tomcat-5.5.17
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=/opt/netbeans-5.5/enterprise3/apache-tomcat-5.5.17/common/lib/servlet-api.jar

content of $HOME/.bashprofile

GNU nano 1.3.12 File: /root/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

# User specific environment and startup programs


export PATH



i have added CLASSPATH variable with the value /path_to_tomcat/common/bin/servlet.api.jar in the /etc/profile
then i have compiled and class file is created in the pwd
How to run this servlet form the browser
i have saved the in /path_to_tomcat/webapps/my_apps/WEB-INF/
and a class file is created in this directory
How to call this servlet form the browser

I think you will be frustating to answer the strange problems of newbies like me....what do u feel....???
I am very thankful to you for having taken time to answer my questions ..
No query of mine in this forum had these many replies that too from a single user.....

Last edited by me4linux; 03-09-2007 at 08:00 AM.
Old 03-09-2007, 06:48 AM   #2
Senior Member
Registered: Dec 2005
Location: Indiana
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790

Rep: Reputation: 57
Please see and adjust to your configuration:
Old 03-09-2007, 07:43 AM   #3
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 132Reputation: 132

Two remarks to begin with:

1) You shouldn't save your .java and .class files to your desktop, you'll make a complete mess. Place them in /home/username instead.
2) You don't need to be root to write and compile your java file in your home directory (that's the whole point of working in your home directory: it's the one place where a regular user can do pretty much as (s)he likes). If you work as root, you could (and probably will some day) make a mistake that destroys your system. Only become root when you need to move your files to a different directory. To make it work as a regular user, you need to edit the bash_profile in your own home directory as I described before (not in the root directory).

Now, your problem. I don't really see why java Hello should fail this time if you did exactly what you did the first time. Let's go over the commands you used:

Vi was good for an example, but it may be easier to use another text editor, e.g. "gedit" or "leafpad". You could launch these directly by clicking their menu item instead of launching them from the command line.

If you don't receive any errors, then you're doing fine.

java Hello
NoClassDefFoundError basically means that java doesn't find the Hello.class file. That beats me. If you were able to compile in that directory, I don't see why you shouldn't be able to run the class file from there as well. Are you absolutely sure you didn't make any error (java is very sensitive to even the tiniest error: forgetting a space or writing a capital instead of a regular letter can be enough to get an exception or an error!).

As for uploading to tomcat, I wouldn't do it the way you did it. I've always placed my stuff in a war file before uploading and I wouldn't be surprised if that's the only way to make it work.

Anyway, use netbeans, that'll take care of everything (editing, paths, compilation, uploading,...)

Here's just one example. As I said, I can't possibly even begin to show you how it works because there's so much to it. and the same goes, in fact, for Java, JSP and Servlets: it took me 3000 pages to become proficient so it's an illusion that I could teach you even the basic skills in a couple of posts. I suggest you look on the internet for some good tutorials. Start by learning some java, then do jSP and servlets (I think doing servlets without knowing java is pretty impossible because you need java to write them).

Anyway, the netbeans example:

1) launch netbeans from the menu or from the desktop item
2) First check whether it is pointing towards your jdk (you need to do that only the first time):
go to /Tools/Java Platform; it should be pointing to /opt/jdk1.6.0 if that's where your jdk is
3) Next you define your server: go to Tools/Server Manager: replace the default username and password with your own (this too needs be done only once)
4) Click File/new Project
5) Select Web and Web Application; click next
6) Define the project name (for example, myfirstservlet) and specify the Project Location (/home/username); leave the rest as it is
7) Click Next
8) Click Finish
9) Right-click on the project name in the left pane so a dialog pops up; select new; select servlet
10) Assign a Class name: for example, TestingServlet (I think that's what yours was called, right?) and define a Package: for example, com.me4linux.servlets
11) Click next and change the first letter of "URL pattern" with a regular letter (not a capital letter); do not delete the / or the rest of the word! Click Finish.
12) Now write your servlet: delete all the stuff from "response.setContentType" to "out.close()" and replace it with your own stuff.
13) In the left pane, under project name, unfold the directory tree and unfold Packages; select your servlet, do a right-click and click on Compile. If you get errors, there are mistakes in your servlet, you'll have to edit it first and then try compiling again until you get it right.
14) Next right-click on the project name in the left pane and select Deploy Project (netbeans will now upload your project/servlet to its tomcat server).
15) To see the page, you launch a browser and define the location of your servlet:

http://localhost:XXXX/name of the project/url pattern of the servlet
where XXXX is the port assigned to your Tomcat (look under Tools/Server Manager for the number: it's 4 digits)
Where name of the project is the name you defined while making the project
Where url pattern is the pattern defined while making the servlet

if your port is, say, 8080 and you adopted all the values I suggested, you should use:

Note: don't click on the urls above; they're just examples but this forum seems to turn them into real links no matter what I do.

Note: using localhost on Fedora is a bit inconvenient at this time; you can use instead of localhost.

Last edited by jay73; 03-09-2007 at 07:49 AM.
Old 03-09-2007, 11:38 AM   #4
Registered: Aug 2004
Location: Hyderabad, India
Distribution: Fedora Core 4
Posts: 183

Rep: Reputation: 30
Try the commands

which java
which javac

If its showing /usr/bin/java, it means its not using the correct java interpreter.

For this you should use
export PATH="/opt/jdk1.6.0/bin:$PATH"
somewhere in your shell, bashrc, etc.
Old 03-09-2007, 12:03 PM   #5
Senior Member
Registered: Dec 2005
Location: Indiana
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790

Rep: Reputation: 57
To _UnPrEdictAbLe_


$ ls -al /usr/bin/javac
lrwxrwxrwx 1 root root 27 Feb 20 08:35 /usr/bin/javac -> /usr/java/default/bin/javac
$ ls -al /usr/java/default/bin/javac
-rwxr-xr-x 1 root root 52088 Nov 29 05:14 /usr/java/default/bin/javac

$ which java
$ ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22 Feb 20 08:35 /usr/bin/java -> /etc/alternatives/java
$ ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 27 Feb  7 15:24 /etc/alternatives/java -> /usr/java/jre1.6.0/bin/java
$ ls -al /usr/java/jre1.6.0/bin/java
-rwxr-xr-x 1 root root 47116 Nov 29 06:24 /usr/java/jre1.6.0/bin/java
$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

Last edited by Lenard; 03-09-2007 at 12:09 PM.
Old 03-09-2007, 02:16 PM   #6
Registered: Aug 2006
Distribution: Fedora 7
Posts: 165

Original Poster
Rep: Reputation: 30
Hi everyone [especially jay73]

I have reinstalled fedora core 6 i386 yesterday
and i have got the binary installtion file for netbeans

Please explain me the steps in detail..
Being a newbie to linux I am fed up with reinstalling Fedora many times and messing up with may things
Please help me to start java in fedora

waiting for a nice reply

Old 03-09-2007, 02:27 PM   #7
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 132Reputation: 132
You don't know how to install it, that's it?

Move the bin file to /opt
cd to /opt
As root, make the file executable: chmod a+x ./jdk*
Then you install it: ./jdk*bin
Old 03-10-2007, 03:33 AM   #8
Registered: Aug 2004
Location: Hyderabad, India
Distribution: Fedora Core 4
Posts: 183

Rep: Reputation: 30
In order to install the bin file, login as root.

chmod 755 jdk-6-nb-5_5-linux.bin

This will throw up a graphical interface. Install the jdk in /opt folder. It will also ask you to install netbeans in the /opt/netbeans-5.5 folder. After the installation finishes, you need to add the javac and java in the path.

For that, you need to add these lines to /etc/bashrc
export PATH="/opt/jdk1.6.0/bin:$PATH"
(/opt/jdk1.6.0/bin should be replaced with whatever directory it is actually creating in /opt)

The netbeans executable will be in /opt/netbeans-5.5/bin. Link it to /usr/bin

cd /usr/bin
ln -sf /opt/netbeans-5.5/bin/netbeans

Then you can just type 'netbeans' on konsole or in run and get netbeans up and running. You should also check the jdk netbeans is using in its settings. It should use the /opt/jdk1.6.0 and so on.

Also look for output of
which java
which javac

They should point to executables in /opt and not /usr/bin



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using shell script to change hostname(Fedora Core6) lion1978 Linux - Software 10 03-05-2007 03:14 AM
Fedora Core6 ndiswrapper issue lqamoebafc6 Linux - Wireless Networking 3 01-15-2007 07:58 PM
Problem Ati x700 install Fedora Core6 64bit muratt Linux - Hardware 0 11-09-2006 10:47 AM
Enabe Netbeans with Java Tiger (1.5) trumpetdork Programming 6 05-01-2005 03:56 PM
Java: Netbeans IDE question ludeKing Programming 0 09-01-2004 10:20 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration