Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-09-2005, 01:14 PM   #1 (permalink)
Broken In
 
Join Date: Oct 2004
Posts: 162
Default help in java program


i wrote a program in java

it is complilng ok,but it is giving error runtime in dos prompt

H:\shivi>java Pg2
Exception in thread "main" java.lang.NoClassDefFoundError: Pg2


this is the program
public class Pg2
{
public static void main(String[] args)
{
int m=1,i;
while(m<=5)
{
i=1;
while(i<=m)
{
System.out.print(" "+i);
i++;

}
System.out.println("");
m++;
}

}
}

but when in run the program in idelike dr java it is not giving any error
shivi4 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 07-09-2005, 05:23 PM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default

Well, this happens to me also sometimes but not after i change something in the code.
try removing the public b'fore the class coz u dont need it in this program (not really necessary).

Also if the problem persists plz try to do a re-install of the SDK.

It happens rarely to me but i dont know what the problem exactly is coz the code is ok.

Even for me in Eclipse i get no errors.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 07-09-2005, 06:40 PM   #3 (permalink)
Wise Old Owl
 
aadipa's Avatar
 
Join Date: Feb 2004
Location: Palghar, Mumbai
Posts: 1,000
Default

1. Check your CLASSPATH environmental variable. You must set it to current directory. Try this command
Code:
SET CLASSPATH=.;%CLASSPATH%
2. I feel stupid to ask this, but did u first compiled the program using javac ?
__________________
i generally prefer quality over quantity
1 aadi + 1 aadi = 1 full ;)
aadipa is offline  
Old 08-09-2005, 07:27 AM   #4 (permalink)
Broken In
 
Join Date: Oct 2004
Posts: 162
Default

thank you it worked by giving class path
shivi4 is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by soumya
- by clinton
- by Who
- by Sujeet
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 11:23 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2