Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3322776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:13:23+00:00 2026-05-17T23:13:23+00:00

I have two Java class files: primegen and primecheck sitting in the same directory.

  • 0

I have two Java class files: primegen and primecheck sitting in the same directory. primegen calls a public static function from primecheck. primecheck compiles fine.

However, I receive the following compilation error in primegen:

primegen.java:31: cannot find symbol
symbol  : variable primecheck
location: class primegen
          } while (!primecheck.prime(primeCandidate));
                ^

Shouldn’t Java be checking other (compiled) classes within the same directory? Does Java have a problem with primecheck being in lower-case letters (e.g. Is it treating primecheck as a variable instead of a class?)?

Update with Complete Code

Code for primegen:

import java.math.BigInteger;
import java.util.Random;

public class primegen
{

    public static void main(String args[])
    {
        try
        {
            int numBits = Integer.parseInt(args[0].trim());
            System.out.println(generatePrime(numBits));
        }
        catch (Exception e)
        {
            System.out.println("You must enter a positive integer number of bits.");
        }
    }

    private static BigInteger generatePrime(int numBits) throws Exception
    {
        if (numBits < 1)
            throw new Exception("You must enter a positive integer number of bits.");

        BigInteger primeCandidate;
        Random rand = new Random();

        do
        {
            primeCandidate = new BigInteger(numBits, rand);
        } while (!primecheck.prime(primeCandidate));

        return primeCandidate;
    }

}

Code for primecheck:

import java.math.BigInteger;
import java.util.Random;

public class primecheck
{

    public static void main(String args[])
    {
        try
        {
            BigInteger primeCandidate = new BigInteger(args[0].trim());
            if (prime(primeCandidate))
                System.out.println("True");
            else
                System.out.println("False");
        }
        catch (Exception e)
        {
            System.out.println("You must enter a positive integer.");
        }
    }

    public static boolean prime(BigInteger n) throws Exception
    {
        if (n.compareTo(BigInteger.ZERO) == -1)
            throw new Exception("You must enter a positive integer.");
        else if (n.equals(BigInteger.ZERO) || n.equals(BigInteger.ONE))
            return false;

        int maxIterations = 1000;
        BigInteger a;

        for (int i = 0; i < maxIterations; i++)
        {
            a = randomBase(n);
            a = a.modPow(n.subtract(BigInteger.ONE), n);

            if (!a.equals(BigInteger.ONE))
                return false;
        }

        return true;
    }

    private static BigInteger randomBase(BigInteger n)
    {
        Random rand = new Random(); 
        BigInteger a;

        do
        {
            a = new BigInteger(n.bitLength(), rand);
        } while ( !(BigInteger.ONE.compareTo(a) <= 0 && a.compareTo(n) < 0) );

        return a;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:13:24+00:00Added an answer on May 17, 2026 at 11:13 pm

    Java does not care about names being all lowercase or uppercase. These are just naming conventions (Java is case sensitive, but will not enforce any particular naming convention).

    Edit: (after a few iterations 🙂

    The code you posted compiles fine. The problem is obviously somewhere else (javac command line arguments, classpath…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have two .java files. The Main.java: public class Main { static
I have two entities A and B: A.java: ... public class A implements Serializable
I have two java files in a directory, neither of them are in a
I have two Java interfaces and one implementing class. (I have used Eclipse to
I have two java classes as follows App1 without a package: class App1 {
So we have a java class with two ArrayLists of generics. It looks like
In C# .net there is a provision to have two different class files and
I have two jar files. MyProduct.jar (The business logic) MyProductFixture.jar. (The fixture that calls
i have two java files file1 and file2 as follows in package pak file1:
I'm learning Java am having trouble running an example program. I have two files:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.