473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On java program running on ubuntu

129 New Member
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.NoCla ssDefFoundError : java/Hello.java
at gnu.java.lang.M ainThread.run(l ibgcj.so.7)
Caused by: java.lang.Class NotFoundExcepti on: java/Hello.java
at java.lang.Class .forName(libgcj .so.7)
at gnu.java.lang.M ainThread.run(l ibgcj.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 1733
JosAH
11,448 Recognized Expert MVP
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 New Member
Hello friend,
After running class file also i am getting the following error:

Exception in thread "main" java.lang.NoCla ssDefFoundError : Hello.class
at gnu.java.lang.M ainThread.run(l ibgcj.so.7)
Caused by: java.lang.Class NotFoundExcepti on: Hello.class not found in gnu.gcj.runtime .SystemClassLoa der{urls=[file:./], parent=gnu.gcj. runtime.Extensi onClassLoader{u rls=[], parent=null}}
at java.net.URLCla ssLoader.findCl ass(libgcj.so.7 )
at java.lang.Class Loader.loadClas s(libgcj.so.7)
at java.lang.Class Loader.loadClas s(libgcj.so.7)
at java.lang.Class .forName(libgcj .so.7)
at gnu.java.lang.M ainThread.run(l ibgcj.so.7)
Apr 15 '08 #3
JosAH
11,448 Recognized Expert MVP
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 New Member
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
3624
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 sci-fi space game in about 2 weeks (www.andromedaonline.net) We have multiple servers, but the game engine (Game Server Program) is a Java program...
11
9217
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 C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
30
2763
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 took .5 seconds to complete on my 400 Mhz PC while the Java program took 6.5 seconds. I am running the SUSE 8.2 Linux distribution. Why is Java...
2
3134
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 procedures. It is enabled for SQL stored procedures. It is possible to "Build" and "Run" the Java SPs, it just isn't possible to click on the...
1
9596
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
5
1770
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 simulation needed to loop and I got a massive speedup by putting that loop in C. I'm basically manipulating a bunch of matrices, so nothing too fancy. ...
2
3249
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 ="C:\InstantRails\php\extensions\php_java.jar;C:\JavaSources\MyStuff" java.home = "C:\Program Files\Java\jdk1.5.0_10;C:\Program Files\Java\jre1.5.0_10\lib"
3
2255
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 what's displayed, for examples: the button can't be pressed, the combo box can't be schrolled, etc. One thing that make me confused is threre's no error...
1
1997
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 program to help tally election results. There are two candidates for office -- Polly Tichen and Ernest Orator. The program's job is to take as input the...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.