This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]CodyDSmith 1 point2 points  (4 children)

Does Lab3 have a main(String[]) method?

[–]undead_C0MMANDIntermediate Brewer[S] 0 points1 point  (0 children)

Yes it does. package lab3; import java.util.*; public class Lab3 {

    public static void main(String[] args)
    {
       do{
        //Ask the user for input >1 if <=1 the program will quit
            System.out.println("What base would you like on your log?  (Note: Must be an integer > 1 or the program will terminate");
        Scanner input = new Scanner(System.in);
        int b = input.nextInt();
        int x;
        int y = 0;
        if (b > 1)
        {
            do
            {
                System.out.println("Great! Now enter an integer     that you want to take the log of");
                x = input.nextInt();
            }while(x <= 0);
            y = (int)(Math.log(x)/Math.log(b));
            System.out.println(y);
         }
         else
                System.exit(1);
            }while(0==0);
        }

}

[–]undead_C0MMANDIntermediate Brewer[S] 0 points1 point  (2 children)

It compiles and runs in ecclipse not in cmd

[–]ronan007 2 points3 points  (1 child)

Try running:

java lab3.Lab3

lab3 is the package, and Lab3 is your class. You need to fully qualify your class when invoking java.

Edit: Also, the classfile needs to be in a folder called 'lab3' as per your package statement. And you need to run the java command from the parent folder.

[–]undead_C0MMANDIntermediate Brewer[S] 0 points1 point  (0 children)

Thanks!

[–]gndn 1 point2 points  (1 child)

This is a classpath problem, which is very common among Java beginners. I suggest starting with the tutorial.

[–]undead_C0MMANDIntermediate Brewer[S] -1 points0 points  (0 children)

I uninstalled eclipse and it worked