Hello there,
I'm brand new to Java and have. I'm taking my 2nd Java class at school and I'm pretty lost at this point.
The main problem I'm having right now is I cannot get my code to execute. My code will compile, but when I try to execute it, either just using the "java" command or executing from TextPad, I get the following error:
Exception in thread "main" java.lang.NoCla ssDefFoundError : MortgagePayment 1
Press any key to continue . . .
In my last class, my compiler was working fine and I could easily execute all of my applications. However, I stupidly ran Windows Updates and it installed Java 6 on my computer and nothing has worked right since.
When I execute "java -version" from a command line, this is what I get:
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
Here's the code I've compiled and am trying to execute:
import javax.swing.*;
import java.awt.*;
import java.awt.event. *;
import javax.swing.bor der.*;
import java.text.Decim alFormat;
public class MortgagePayment 1 extends JFrame implements ActionListener
{
private JTextField mortgageAmount;
private JTextField mortgageTerm;
private JTextField interestRate;
private JTextField mortgagePayment Amount;
private JButton calculateBtn;
private JButton quitBtn;
public MortgagePayment 1() {
JPanel contentPane = (JPanel)getCont entPane();
contentPane.set Layout(new BorderLayout(0, 4));
JPanel northPanel = new JPanel();
Border b = BorderFactory.c reateEtchedBord er();
northPanel.setB order(BorderFac tory.createTitl edBorder(b, "Calculate Mortgage Payment", TitledBorder.TO P, TitledBorder.CE NTER));
northPanel.setL ayout(new GridLayout(4, 2, 10, 10));
JLabel mortgageAmountL abel = new JLabel("Input Initial Mortgage Amount (dollars)", JLabel.RIGHT);
JLabel mortgageTermLab el = new JLabel("Input Mortgage Term (years)", JLabel.RIGHT);
JLabel interestRateLab el = new JLabel("Input Interest Rate", JLabel.RIGHT);
JLabel mortgagePayment AmountLabel = new JLabel("Mortgag e Payment Amount", JLabel.RIGHT);
mortgageAmount = new JTextField(10);
mortgageTerm = new JTextField(10);
interestRate = new JTextField(10);
mortgagePayment Amount = new JTextField(10);
northPanel.add( mortgageAmount) ;
northPanel.add( mortgageTerm);
northPanel.add( interestRate);
northPanel.add( mortgagePayment Amount);
northPanel.add( mortgageAmountL abel);
northPanel.add( mortgageTermLab el);
northPanel.add( interestRateLab el);
northPanel.add( mortgagePayment AmountLabel);
// add the rest of labels and textfields
JPanel southPanel = new JPanel();
calculateBtn = new JButton("Calcul ate");
southPanel.add( calculateBtn);
calculateBtn.ad dActionListener (this);
quitBtn = new JButton("Quit") ;
southPanel.add( quitBtn);
quitBtn.addActi onListener(this );
contentPane.add (northPanel, BorderLayout.NO RTH);
contentPane.add (southPanel, BorderLayout.SO UTH);
}
public void actionPerformed (ActionEvent evt)
{
JButton sourceBtn = (JButton)evt.ge tSource();
if (sourceBtn == calculateBtn)
{
//calculate monthly payment
//.... set mortgagePayment Amount textfield to monthly payment.
}
else if (sourceBtn == quitBtn)
{
System.exit(0);
}
}//close actionPerformed method
public static void main(String[] args)
{
MortgagePayment 1 mp1 = new MortgagePayment 1();
mp1.setTitle("M ortgage Payment: Assignment 1 developed by ...");
mp1.pack();
mp1.addWindowLi stener(new WindowAdapter()
{
public void windowClosing(W indowEvent e)
{
Window w = e.getWindow();
w.setVisible(fa lse);
w.dispose();
System.exit(0);
}//close windowClosing method
});//close addWindowListen er method
mp1.setVisible( true);
}//close Main method
}//close MortgagePayment 1 class
Any help would be greatly appreciated.
I'm brand new to Java and have. I'm taking my 2nd Java class at school and I'm pretty lost at this point.
The main problem I'm having right now is I cannot get my code to execute. My code will compile, but when I try to execute it, either just using the "java" command or executing from TextPad, I get the following error:
Exception in thread "main" java.lang.NoCla ssDefFoundError : MortgagePayment 1
Press any key to continue . . .
In my last class, my compiler was working fine and I could easily execute all of my applications. However, I stupidly ran Windows Updates and it installed Java 6 on my computer and nothing has worked right since.
When I execute "java -version" from a command line, this is what I get:
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
Here's the code I've compiled and am trying to execute:
import javax.swing.*;
import java.awt.*;
import java.awt.event. *;
import javax.swing.bor der.*;
import java.text.Decim alFormat;
public class MortgagePayment 1 extends JFrame implements ActionListener
{
private JTextField mortgageAmount;
private JTextField mortgageTerm;
private JTextField interestRate;
private JTextField mortgagePayment Amount;
private JButton calculateBtn;
private JButton quitBtn;
public MortgagePayment 1() {
JPanel contentPane = (JPanel)getCont entPane();
contentPane.set Layout(new BorderLayout(0, 4));
JPanel northPanel = new JPanel();
Border b = BorderFactory.c reateEtchedBord er();
northPanel.setB order(BorderFac tory.createTitl edBorder(b, "Calculate Mortgage Payment", TitledBorder.TO P, TitledBorder.CE NTER));
northPanel.setL ayout(new GridLayout(4, 2, 10, 10));
JLabel mortgageAmountL abel = new JLabel("Input Initial Mortgage Amount (dollars)", JLabel.RIGHT);
JLabel mortgageTermLab el = new JLabel("Input Mortgage Term (years)", JLabel.RIGHT);
JLabel interestRateLab el = new JLabel("Input Interest Rate", JLabel.RIGHT);
JLabel mortgagePayment AmountLabel = new JLabel("Mortgag e Payment Amount", JLabel.RIGHT);
mortgageAmount = new JTextField(10);
mortgageTerm = new JTextField(10);
interestRate = new JTextField(10);
mortgagePayment Amount = new JTextField(10);
northPanel.add( mortgageAmount) ;
northPanel.add( mortgageTerm);
northPanel.add( interestRate);
northPanel.add( mortgagePayment Amount);
northPanel.add( mortgageAmountL abel);
northPanel.add( mortgageTermLab el);
northPanel.add( interestRateLab el);
northPanel.add( mortgagePayment AmountLabel);
// add the rest of labels and textfields
JPanel southPanel = new JPanel();
calculateBtn = new JButton("Calcul ate");
southPanel.add( calculateBtn);
calculateBtn.ad dActionListener (this);
quitBtn = new JButton("Quit") ;
southPanel.add( quitBtn);
quitBtn.addActi onListener(this );
contentPane.add (northPanel, BorderLayout.NO RTH);
contentPane.add (southPanel, BorderLayout.SO UTH);
}
public void actionPerformed (ActionEvent evt)
{
JButton sourceBtn = (JButton)evt.ge tSource();
if (sourceBtn == calculateBtn)
{
//calculate monthly payment
//.... set mortgagePayment Amount textfield to monthly payment.
}
else if (sourceBtn == quitBtn)
{
System.exit(0);
}
}//close actionPerformed method
public static void main(String[] args)
{
MortgagePayment 1 mp1 = new MortgagePayment 1();
mp1.setTitle("M ortgage Payment: Assignment 1 developed by ...");
mp1.pack();
mp1.addWindowLi stener(new WindowAdapter()
{
public void windowClosing(W indowEvent e)
{
Window w = e.getWindow();
w.setVisible(fa lse);
w.dispose();
System.exit(0);
}//close windowClosing method
});//close addWindowListen er method
mp1.setVisible( true);
}//close Main method
}//close MortgagePayment 1 class
Any help would be greatly appreciated.
Comment