Getting error "Can't resolve symbol"  getting frustrated

Posted on 2005-03-26
Medium Priority
Last Modified: 2013-11-23
Ok I have a Java program that is calling another program.  The name of the program that has the frame and everything in it is MortApp1.  The program that it is trying to call is Mortcalc2.  The first thing that I did was compile the Mortcalc2 program and then I go and compile the MortApp1 program and I get the following error messages:
C:\Java\help>javac Mortcalc2.java

C:\Java\help>javac MortApp1.java
MortApp1.java:30: cannot resolve symbol
symbol  : class Mortcalc2
location: class MortApp1
    static Mortcalc2 MC2;
MortApp1.java:88: cannot resolve symbol
symbol  : class Mortcalc2
location: class MortApp1
            MC2 = new Mortcalc2(new Double(txtPrincipal.getText()).doubleValue(), new Double(txtRate.ge
tText()).doubleValue(), new Integer(txtTerm.getText()).intValue());

I have gone through this at least 800 zillion times, I am not sure what the problem is.  I am enclosing the frame class first and then below it I will enclose the program that it calls with is MortCalc2.  Any assitance that you can give me would be greatly appreciated.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MortApp1 implements ActionListener {
    // Declare our variables
    static JFrame frame;
    static JPanel contentPane;
    static JPanel pRow1;
    static JPanel pRow2;
    static JPanel pRow3;
    static JPanel pRow4;
    static JPanel pRow5;
    static JLabel lblPrincipal;
    static JLabel lblRate;
    static JLabel lblTerm;
    static JLabel lblMonthlyPaymentLbl;
    static JLabel lblMonthlyPayment;
    static JTextField txtPrincipal;
    static JTextField txtRate;
    static JTextField txtTerm;
    static JButton bCalculate;
    static JButton bQuit;
    static double principal;
    static double rate;
    static int term;
    static double montlypayment;
    static Mortcalc2 MC2;
    private Component createComponents() {
        // Create the panels
        contentPane = new JPanel(new GridLayout(5, 1));
        pRow1 = new JPanel(new GridLayout(1,2,5,0));
        pRow2 = new JPanel(new GridLayout(1,2,5,0));
        pRow3 = new JPanel(new GridLayout(1,2,5,0));
        pRow4 = new JPanel(new GridLayout(1,2,5,0));
        pRow5 = new JPanel(new FlowLayout(FlowLayout.CENTER,5,0));
        // Create and add the components.
        lblPrincipal = new JLabel("Principal:", JLabel.RIGHT);
        txtPrincipal = new JTextField(20);
        lblRate = new JLabel("Rate:", JLabel.RIGHT);
        txtRate = new JTextField(8);
        lblTerm = new JLabel("Term:", JLabel.RIGHT);
        txtTerm = new JTextField(8);
        lblMonthlyPaymentLbl = new JLabel("Monthly Payment:", JLabel.RIGHT);
        lblMonthlyPayment = new JLabel("");
        bCalculate = new JButton("Calculate");
        bQuit = new JButton("Quit");
        // Add sub-panels to content panel
        // Return the content panel
        return contentPane;
    public void actionPerformed(ActionEvent e) {
        // Check which button triggered the event
        if("Calculate".equals(e.getActionCommand())) {
            // Create a string format
            java.text.DecimalFormat dec = new java.text.DecimalFormat("$,###.00");
            // Create a new instance of Mortcalc2 with values from text boxes
            MC2 = new Mortcalc2(new Double(txtPrincipal.getText()).doubleValue(), new Double(txtRate.getText()).doubleValue(), new Integer(txtTerm.getText()).intValue());
            // Set the monthly payment
        else if("Quit".equals(e.getActionCommand())) {
            // Exit the program
    private static void createAndShowGUI() {
        // Set window decorations
        // Create and set up the window.
        frame = new JFrame("mortApp");
        // Create an instance of our application
        MortApp1 app = new MortApp1();
        // Create our components
        Component contents = app.createComponents();
        // Add components to frame
        // Display the window.
        // Don't allow window to be resized
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {

Here is the program that I have getting called:

import java.text.DecimalFormat;
import java.io.*;

public class Mortcalc2      // name of the program
    // global class variables
    private double principal;                                           // loan principal
    private double interestRateYears;                                   // annual interest rate (percentage)
    private double interestRateMonths;                                  // monthly interst rate
    private int termYears;                                              // length of loan in years
    private int termMonths;                                             // length of loan in months
    private double monthlyPayment;                                      // monthly payment

    private double balance;                                             // displays current balance
    private double interestPaid;                                        // displays the interest paid
    private double principalPaid;                                       // displays the principal paid
    private double monthlyInterestPayment;                              // holds current interest payment
    private double monthlyPrincipalPayment;                             // holds current principal payment

    private int currentMonth;

    java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00");

    public Mortcalc2(double p_Principal, double p_Rate, int p_Term)
        // assign values
        principal = p_Principal;                                    // loan principal
        interestRateYears = p_Rate;                                 // annual interest rate (percentage)
        interestRateMonths = (interestRateYears / 12) / 100;        // monthly interest rate
        termYears = p_Term;                                         // length of loan in years
        termMonths = (termYears * 12);                              // length of loan in months
        monthlyInterestPayment = 0;                                 // set current interest payment = 0
        monthlyPrincipalPayment = 0;                                // set current principal payment = 0
        balance = principal;                                        // set current balance = principal

        currentMonth = 1;

        monthlyPayment = (principal * interestRateMonths) /         // calculate monthly payment
            (1 - Math.pow(1 + interestRateMonths, - termMonths));


    public double getMonthlyPayment()
        // return montlyPayment;
        return monthlyPayment;

    public double getMonthlyInterestPayment()
        // return montly interest payment
        return monthlyInterestPayment;

    public double getMonthlyPrincipalPayment()
        // return montly principal payment
        return monthlyPrincipalPayment;

    public double getBalance()
        // return balance
        return balance;

    public void nextMonth()
        if(currentMonth < termMonths + 1)
            // calculate interest and principal payments
            monthlyInterestPayment = (balance * interestRateMonths);
            monthlyPrincipalPayment = (monthlyPayment - monthlyInterestPayment);
            balance = (balance - monthlyPrincipalPayment);

} // End class Mortcalc2
Question by:gschoser
  • 4
LVL 14

Accepted Solution

sudhakar_koundinya earned 2000 total points
ID: 13636780
do this  before you compile

set classpath=%classpath%;.;

Now compile your program

javac *.java
LVL 14

Expert Comment

ID: 13636787
>>set classpath=%classpath%;.;

So that it checks the classes in your current folder.

Means while you are compiling a particular class, if class contains any dependable class objects then JVM can identify the dependable classes also. In your case MortCalc2 in MortApp1
LVL 14

Expert Comment

ID: 13636790
>>set classpath=%classpath%;.;

I presume you know how to set the classpaths at DOS prompt

Sudhakar Chavali
LVL 14

Expert Comment

ID: 13636865

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question