Running Java from Command Line

Code:

`package demo;`

import primeNumbers.Prime;

class DemoClass{

public static void main(String[] args){

Prime prime = new Prime();

System.out.println(prime.isPrime(66));

}

}

**********************************

Code:

`package primeNumbers;`

public class Prime{

public boolean isPrime(int number){

boolean ok = false;

if( number == 0 || number == 1 || number == 2)

return true;

for(int i=2; i <= Math.sqrt(number); i++)

if(number%i == 0)

ok = true;

if(ok)

return false;

else

return true;

}

}

not imorting primeNumbers when I run it from cmd .. theri root directory is mathematics .. ...showing error (package primeNumbers doesnot exist)

package hierarchy is :

mathematics -- ( demo , primeNumbers)

any help ? thanks in advance :(whew):

Re: Running Java from Command Line

When I ran them manually I put them each in

mathematics\demo\DemoClass.java

mathematics\primeNumbers\Prime.java

Then I just compiled them from mathematics like this:

javac demo\DemoClass.java

javac primeNumbers\Prime.java

Then I ran the DemoClass by doing:

java demo.DemoClass

From the mathematics directory

Regards,

Jim

Re: Running Java from Command Line

what i was doing .. i was compiling it being within the demo directory ...

Re: Running Java from Command Line

Re: Running Java from Command Line

0 and 1 aren't prime numbers by definition.

kind regards,

Jos

Re: Running Java from Command Line

k ... thats another topic