+ 1
Why i am getting this error ::exception in thread main java.lang.noclassdeffounderror
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.
+ 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)
{
}
}
}
+ 1
Try to use Scanner()
0
Can you show your code?
0
What I have to do now
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();
0
I edited my last post, code works in command line