Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
package acm1st;
 class Acm1st
{
    private static long i;
    public static void main(String[] args)
    {
             long x=1000000;
             int  y= count(1,x);
             System.out.println(1+"\t"+x);
             if(x%2==0)
             {
               int z=  count(x, x);
               System.out.print(Math.max(z, y));

             }
          System.exit(0);

    }
    private static int count(long x,long y)
        {
           long num =0;int max=1,counter=1;

           for( i=x;i<=y;i+=2)
            {
               num =i;
            while (num != 1)
             {
                if (num % 2 == 0)
                {
                    num/= 2;

                }
                else
                {
                   num = (num * 3) + 1;
                }

                counter++;
             }
            if(max<counter)
                max=counter;
            counter=1;
           }
           return max;
        }

}



Give me This



result: Runtime error time: 0.07s memory: 380160 kB signal: -1
input: no
output: no
stderr:

Exception in thread "main" java.lang.NoClassDefFoundError: Acm1st (wrong name: acm1st/Acm1st)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Posted
Comments
Sudhakar Shinde 9-Apr-13 2:06am    
Please check http://javarevisited.blogspot.in/2011/06/noclassdeffounderror-exception-in.html which will be helpful for resolving the error.
Richard MacCutchan 16-Apr-13 3:33am    
You tried to run this from the wrong directory; acm1st should be a subdirectory of CWD.

1 solution

Some jars are missing, The application is not able to take the build path properly

Configure the build path correctly and test again
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900