Begining to learn Java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Begining to learn Java

  1. #1
    Alfy Guest

    Begining to learn Java


    Hi Everybody

    Am a novice to Java triyng to learn it from scratch. Am referring the Java
    How to Program by Deitel & Deitel

    I tried one of the examples from the book but it pops up following runtime
    error.

    Exception in thread "main" java.lang.NoClassDefFoundError:Comparision.class

    My code is given below :

    import javax.swing.JOptionPane;

    public class Comparision {
    public static void main ( String args[] )
    {
    try
    {
    String firstNumber, secondNumber, result;
    int number1, number2;
    firstNumber = JOptionPane.showInputDialog("Enter first integer:");
    secondNumber = JOptionPane.showInputDialog("Enter second integer:");

    number1 = Integer.parseInt(firstNumber);
    number2 = Integer.parseInt(secondNumber);
    result = "";

    if(number1 == number2)
    result = result + number1 + " == " + number2;
    if(number1 != number2)
    result = result + number1 + " != " + number2;
    if(number1 < number2)
    result = result + "\n" + number1 + " < " + number2;
    if(number1 > number2)
    result = result + "\n" + number1 + " > " + number2;
    if(number1 <= number2)
    result = result + "\n" + number1 + " <= " + number2;
    if(number1 >= number2)
    result = result + "\n" + number1 + " >= " + number2;


    JOptionPane.showMessageDialog( null, result, "Comparision Results",
    JOptionPane.INFORMATION_MESSAGE);

    System.exit( 0 );
    }
    catch (Error err)
    {
    System.out.println("Error Trapped");
    }

    }
    }

    I cant figure out where to look for the error. Can some body help!!!!!!!!!!!!!!!!!!!!!

    Alfy



  2. #2
    Paul Clapham Guest

    Re: Begining to learn Java

    Go back and read the part of the book that tells you how to set your path
    and your classpath. If the book doesn't tell you that, then you need to get
    a better book.

    Alfy <j-_dias_2k@yahoo.com> wrote in message
    news:39ea43b0$1@news.devx.com...
    >
    > Hi Everybody
    >
    > Am a novice to Java triyng to learn it from scratch. Am referring the Java
    > How to Program by Deitel & Deitel
    >
    > I tried one of the examples from the book but it pops up following runtime
    > error.
    >
    > Exception in thread "main"

    java.lang.NoClassDefFoundError:Comparision.class
    >
    > My code is given below :
    >
    > import javax.swing.JOptionPane;
    >
    > public class Comparision {
    > public static void main ( String args[] )
    > {
    > try
    > {
    > String firstNumber, secondNumber, result;
    > int number1, number2;
    > firstNumber = JOptionPane.showInputDialog("Enter first integer:");
    > secondNumber = JOptionPane.showInputDialog("Enter second integer:");
    >
    > number1 = Integer.parseInt(firstNumber);
    > number2 = Integer.parseInt(secondNumber);
    > result = "";
    >
    > if(number1 == number2)
    > result = result + number1 + " == " + number2;
    > if(number1 != number2)
    > result = result + number1 + " != " + number2;
    > if(number1 < number2)
    > result = result + "\n" + number1 + " < " + number2;
    > if(number1 > number2)
    > result = result + "\n" + number1 + " > " + number2;
    > if(number1 <= number2)
    > result = result + "\n" + number1 + " <= " + number2;
    > if(number1 >= number2)
    > result = result + "\n" + number1 + " >= " + number2;
    >
    >
    > JOptionPane.showMessageDialog( null, result, "Comparision

    Results",
    > JOptionPane.INFORMATION_MESSAGE);
    >
    > System.exit( 0 );
    > }
    > catch (Error err)
    > {
    > System.out.println("Error Trapped");
    > }
    >
    > }
    > }
    >
    > I cant figure out where to look for the error. Can some body

    help!!!!!!!!!!!!!!!!!!!!!
    >
    > Alfy
    >
    >




  3. #3
    SPARKWU Guest

    Re: Begining to learn Java


    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >Go back and read the part of the book that tells you how to set your path
    >and your classpath. If the book doesn't tell you that, then you need to

    get
    >a better book.
    >
    >Alfy <j-_dias_2k@yahoo.com> wrote in message
    >news:39ea43b0$1@news.devx.com...
    >>
    >> Hi Everybody
    >>
    >> Am a novice to Java triyng to learn it from scratch. Am referring the

    Java
    >> How to Program by Deitel & Deitel
    >>
    >> I tried one of the examples from the book but it pops up following runtime
    >> error.
    >>
    >> Exception in thread "main"

    >java.lang.NoClassDefFoundError:Comparision.class
    >>
    >> My code is given below :
    >>
    >> import javax.swing.JOptionPane;
    >>
    >> public class Comparision {
    >> public static void main ( String args[] )
    >> {
    >> try
    >> {
    >> String firstNumber, secondNumber, result;
    >> int number1, number2;
    >> firstNumber = JOptionPane.showInputDialog("Enter first integer:");
    >> secondNumber = JOptionPane.showInputDialog("Enter second integer:");
    >>
    >> number1 = Integer.parseInt(firstNumber);
    >> number2 = Integer.parseInt(secondNumber);
    >> result = "";
    >>
    >> if(number1 == number2)
    >> result = result + number1 + " == " + number2;
    >> if(number1 != number2)
    >> result = result + number1 + " != " + number2;
    >> if(number1 < number2)
    >> result = result + "\n" + number1 + " < " + number2;
    >> if(number1 > number2)
    >> result = result + "\n" + number1 + " > " + number2;
    >> if(number1 <= number2)
    >> result = result + "\n" + number1 + " <= " + number2;
    >> if(number1 >= number2)
    >> result = result + "\n" + number1 + " >= " + number2;
    >>
    >>
    >> JOptionPane.showMessageDialog( null, result, "Comparision

    >Results",
    >> JOptionPane.INFORMATION_MESSAGE);
    >>
    >> System.exit( 0 );
    >> }
    >> catch (Error err)
    >> {
    >> System.out.println("Error Trapped");
    >> }
    >>
    >> }
    >> }
    >>
    >> I cant figure out where to look for the error. Can some body

    >help!!!!!!!!!!!!!!!!!!!!!
    >>
    >> Alfy
    >>
    >>

    >
    >

    Hi!
    you don't SET CLASSPATH
    SUCH AS: C:\>SET CLASSPATH=%CLASSPATH%;.;D:\JDK1.3.0_01\LIB\TOOLS.JAR
    IT'S TEMPORARY! WHEN YOU CLOSE DOS COMMAND!
    YOU CAN START>CONTROL PANEL>SYSTEM>ENVIRONMENT>CLASSPATH
    SET COMMAND SUCH AS:\OEM21\orb\classes\yoj.jar;D:\OEM21\orb\classes\share.zip;.;D:\JDK1.3.0_01\LIB\TOOLS.JAR
    CAREFUL . IT'S VERY IMPORTANT!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center