473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

On java program running on ubuntu

129 100+
Hello friends,
I installed java with the following command:
sudo apt-get update
synaptic
In synaptic i searched for sun-java6-jdk and marked and applied.

After that i wrote a program and complied with javac /java/Hello.java it showed no errors and i run the program with java /java/Hello.java and it shows the follwing errors

Exception in thread "main" java.lang.NoClassDefFoundError: java/Hello.java
at gnu.java.lang.MainThread.run(libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: java/Hello.java
at java.lang.Class.forName(libgcj.so.7)
at gnu.java.lang.MainThread.run(libgcj.so.7)

I think it is for not setting classpath and anybody helps me for setting classpath How to set classpath? and where to set classpath? in ubuntu
Apr 15 '08 #1
4 1728
JosAH
11,448 Expert 8TB
Don't try to run the source file Hello.java, simply run the Hello class file. (no .class
extension used, the VM figures it out).
You do have to compile your source file Hello.java though.

kind regards,

Jos
Apr 15 '08 #2
sasimca007
129 100+
Hello friend,
After running class file also i am getting the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: Hello.class
at gnu.java.lang.MainThread.run(libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: Hello.class not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.Class.forName(libgcj.so.7)
at gnu.java.lang.MainThread.run(libgcj.so.7)
Apr 15 '08 #3
JosAH
11,448 Expert 8TB
Go to the directrory where your compiled Hello.class file is stored. Type this:

Expand|Select|Wrap|Line Numbers
  1. java -cp . Hello
  2.  
This tells the VM (java) to look for classes in the current directory (the dot).

kind regards,

Jos
Apr 15 '08 #4
satch
23
Go to the directrory where your compiled Hello.class file is stored. Type this:

Expand|Select|Wrap|Line Numbers
  1. java -cp . Hello
  2.  
This tells the VM (java) to look for classes in the current directory (the dot).

kind regards,

Jos
Alternatively you can add the path to the directory, where the compiled Hello.class is created, to the CLASSPATH environment variable(though -cp option is the preferred approach).
For details on java classpath read the following link :
http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/classpath.html
Apr 16 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: BlackHawke | last post by:
Hello! This is my second post. Ppl really helped me with the first. I hope there are answers for this one as well I own a game company (www.aepoxgames.net) releasing the beta for our first...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
30
by: Mike Cox | last post by:
Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
5
by: Per B. Sederberg | last post by:
Hi Everybody: I'm having a difficult time figuring out a a memory use problem. I have a python program that makes use of numpy and also calls a small C module I wrote because part of the...
2
by: Janna | last post by:
I have the Java JVM installes on my server. I uncommented extension=php_java.dll in php.ini I uncommented and proerpyl filled out the section in php.ini: java.class.path...
3
by: suryawati | last post by:
Dear All, I am running a java serial program ( Black Box on commapi package ) on a Linux. But when Main Menu can displayed, automatically program stop for running and I can't do anything with...
1
by: mshroom12 | last post by:
Hello to all. I am having difficulty trying to do this Java project using Eclipse. The following is what I have to do. Election Day It's almost election day and the election officials need a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.