Why i am getting this error ::exception in thread main java.lang.noclassdeffounderror | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why i am getting this error ::exception in thread main java.lang.noclassdeffounderror

21st Jul 2019, 4:01 PM
Channu Angadi
7 Answers
+ 12
By googel It occurs when javaruntime system doesn't find a class definition, which is present at compile time, but missing at run time. ... It is thrown by the Java Runtime System.
21st Jul 2019, 5:10 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 1
import java.io.*; class Work { public static void main(String args[]) { try { DataInputStream dis=new DataInputStream(System.in); System.out.println("enter hours of work"); String x=dis.readLine(); int hrs=Integer.parseInt(x); int hours=50; int ot=0,ota=0; if(hours>70) { ot=hours-50; ota=ot*5; } else if(hours>60) { ot=hours-50; ota=ot*5; } else if(hours>50) { ot=hours-50; ota=ot*5; } System.out.println("the hours="+hours); System.out.println("the ot="+ot); System.out.println("the ota="+ota); } catch(IOException e) { } } }
21st Jul 2019, 5:09 PM
Channu Angadi
+ 1
Try to use Scanner()
21st Jul 2019, 5:16 PM
Dwi Novianto Nugroho
Dwi Novianto Nugroho - avatar
0
Can you show your code?
21st Jul 2019, 4:05 PM
Dwi Novianto Nugroho
Dwi Novianto Nugroho - avatar
0
What I have to do now
21st Jul 2019, 5:11 PM
Channu Angadi
0
your posted code works if I run it from command line, bat has problem on SoloLearn with DataInputStream, it reads null You can use BufferedReader dis = new BufferedReader(new InputStreamReader(System.in)); or use Scanner and delete try catch then it works on SL public static void main(String args[]) { Scanner dis=new Scanner(System.in); System.out.println("enter hours of work"); String x=dis.nextLine();
21st Jul 2019, 8:00 PM
zemiak
0
I edited my last post, code works in command line
22nd Jul 2019, 1:44 AM
zemiak