473,418 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Could not find the main class: javaapplication3.Main

1
Hello,

Ive found this site very helpful in the past, so i thought i may ask for help.

I am developing an application for a school project. I am in the middle of it, I get the error: java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:991)
at java.lang.Double.parseDouble(Double.java:510)
at javaapplication3.Main.<clinit>(Main.java:18)
Could not find the main class: javaapplication3.Main. Program will exit.
Exception in thread "main" Java Result: 1

It cannot find the main class, ive tried everything i can think of and a fair bit of looking around on the net for solutions but to no avail.

its pretty urgent as i cant proceed because i cant test, any help would be much appreciated!

Expand|Select|Wrap|Line Numbers
  1. package ChadstoneCommunityBank;
  2.  
  3. import javax.swing.*;
  4. import java.util.ArrayList;
  5.  
  6. public class main {
  7.  
  8.         private static ArrayList<ChequeAccount> ChequeAccount = new ArrayList<ChequeAccount>();
  9.         private static  ArrayList<InvestmentAccount> InvestmentAccount = new ArrayList<InvestmentAccount>();
  10.         private static ArrayList<PassbookAccount> PassbookAccount = new ArrayList<PassbookAccount>();
  11.         private static String name, address, balance, overdraft;
  12.         private static double Balance = Double.parseDouble(balance);
  13.         private static double Overdraft = Double.parseDouble(overdraft);
  14.  
  15.    public static void main(String[] args)
  16.  
  17.        int choice = mainMenu(); //Menu System
  18.         while(choice != 8)
  19.         {
  20.             switch(choice)
  21.             {
  22.                 case 1:
  23.                     createAccount();
  24.                     break;
  25.                 case 2:
  26.                     //addStudent();
  27.                     break;
  28.                 case 3:
  29.                     //printDetails();
  30.                     break;
  31.                 case 4:
  32.                     //createSubject();
  33.                     break;
  34.                 case 5:
  35.                     //addInterest();
  36.                     break;
  37.                 case 6:
  38.                     //printDetails();
  39.                     break;
  40.                 case 7:
  41.                     //createSubject();
  42.                     break;
  43.                 default:
  44.                     JOptionPane.showMessageDialog(null, "Not a valid option, select again");
  45.  
  46.             }
  47.             choice = mainMenu();
  48.         }
  49.         System.exit(0);
  50.     }
  51. //-----------------------------------------------------------------------------------------------------------------------------------------------
  52.     public static int mainMenu()
  53.     {
  54.         String displayMenu;
  55.         displayMenu = JOptionPane.showInputDialog(null, "1.   Add New Account\n2.   Withdraw\n3.   Deposit\n4.   Update Overdraft\n5.   Add Interest\n6.   Print Balance\n7.   Print All\n8.   Quit\n\nEnter Your Option (Enter 8 to quit):");
  56.         int temp = validateMenuInput(displayMenu);
  57.         return temp;
  58.     }
  59.  
  60. //------------------------------------------------------------------------------------------------------------------------------------------------
  61.             public static int validateMenuInput(String aString)
  62.     {
  63.         if (aString.length()<1 || aString==null)//User didnt Enter a selection
  64.         {
  65.             JOptionPane.showMessageDialog(null,"Not A Valid Option, Please Input a Number!");
  66.             return 0;
  67.         }
  68.         else
  69.             if(!Character.isDigit(aString.charAt(0))||(aString.length()>1)) //User Entered a Character
  70.             {
  71.                 JOptionPane.showMessageDialog(null,"Not An Valid Option, Please Input a Number!");
  72.                 return 0;
  73.             }
  74.             else
  75.                 return (Integer.parseInt(aString));
  76.  
  77.     }
  78.  
  79. //-------------------------------------------------------------------------------------------------------------------------------------------------------
  80.  
  81.        //  public static double addInterest(double rate)
  82.        //  {
  83.          //    balance = BankAccountgetBalance();
  84.          //    balance = balance * (1 + (rate/100.0));
  85.  
  86.          //    return balance;
  87.         // }
  88.  
  89.  
  90. //-------------------------------------------------------------------------------------------------------------------------------------------------------
  91. //Create Account Menu
  92.         public static void createAccount()
  93.         {
  94.                int choice = addAccount(); //Menu System
  95.         while(choice != 3)
  96.         {
  97.             switch(choice)
  98.             {
  99.                 case 1:
  100.                     createChequeAccount();
  101.                     break;
  102.                 case 2:
  103.                     createPassbookAccount();
  104.                     break;
  105.                 case 3:
  106.                     createInvestmentAccount();
  107.                     break;
  108.  
  109.                 default:
  110.                     JOptionPane.showMessageDialog(null, "Not a valid account type, Please try again");
  111.  
  112.             }
  113.             choice = addAccount();
  114.         }
  115.  
  116.         }
  117.  
  118.        public static int addAccount()
  119.     {
  120.         String displayMenu;
  121.         displayMenu = JOptionPane.showInputDialog(null, "1.   Cheque Account\n2.   Passbook Account\n3.   Investment Account");
  122.         int temp = validateMenuInput(displayMenu);
  123.         return temp;
  124.     }
  125.  
  126. //------------------------------------------------------------------------------------------------------------------------------------------------
  127. //Create Account Methods
  128.        public static void createChequeAccount()
  129.        {
  130.                 //Ask for New account information
  131.                 name = JOptionPane.showInputDialog(null, "Enter Account Holders Name");
  132.                 address = JOptionPane.showInputDialog(null, "Enter Account Holders Address");
  133.                 balance = JOptionPane.showInputDialog(null, "Enter Opening Balance");
  134.                 overdraft = JOptionPane.showInputDialog(null, "Enter Overdraft Amount");
  135.  
  136.                 //Add account to Array
  137.             ChequeAccount ca = new ChequeAccount(name, address, Balance, Overdraft);
  138.             ChequeAccount.add(ca);
  139.                 //Display New account information
  140.                         int size = ChequeAccount.size()-1;
  141.                         JOptionPane.showMessageDialog(null, "Account information" + ChequeAccount.get(size));
  142.        }
  143.  
  144.        public static void createPassbookAccount()
  145.        {
  146.                 //Ask for New account information
  147.                 name = JOptionPane.showInputDialog(null, "Enter Account Holders Name");
  148.                 address = JOptionPane.showInputDialog(null, "Enter Account Holders Address");
  149.                 balance = JOptionPane.showInputDialog(null, "Enter Opening Balance");
  150.  
  151.                 //Add account to Array
  152.             PassbookAccount pa = new PassbookAccount(name, address, Balance);
  153.             PassbookAccount.add(pa);
  154.        }
  155.  
  156.        public static void createInvestmentAccount()
  157.        {
  158.                 //Ask for New account information
  159.                 name = JOptionPane.showInputDialog(null, "Enter Account Holders Name");
  160.                 address = JOptionPane.showInputDialog(null, "Enter Account Holders Address");
  161.                 balance = JOptionPane.showInputDialog(null, "Enter Opening Balance");
  162.  
  163.                 //Add account to Array
  164.             InvestmentAccount ia = new InvestmentAccount(name, address, Balance);
  165.             InvestmentAccount.add(ia);
  166.        }
  167.  
  168. //---------------------------------------------------------------------------------------------------------------------------------------------------
  169.  
  170.  
  171. }
Jun 10 '10 #1
1 2744
jkmyoung
2,057 Expert 2GB
The initialization of your variables are wrong:

private static String name, address, balance, overdraft;
private static double Balance = Double.parseDouble(balance);
private static double Overdraft = Double.parseDouble(overdraft);

balance and overdraft have not been set, so they will throw errors when the program is run.

Suggestion:
declare the double s but do not set them yet:
private static double Balance,Overdraft;

whenever you change balance and overdraft, set Balance and Overdraft respectively.
Jun 10 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alan.J.Thackray | last post by:
I am new to Java. Since the "main" class has the main() function it it, is this called before the constructor, or is a constructor totally irrelevant for a main class, since you never "new" it ?...
10
by: Ray Z | last post by:
hi, there I build a Class Library, I write a class A to implement interface IA. The problem is when I give the dll file to others, thet can get all information about not only IA, but also A. They...
3
by: koffieautomaat | last post by:
I've made one solution containing two projects. The first projects contains a control libary (dll) with a reusable class. The other projects contains a from which i wanna talk to the dll made by...
0
by: Nunez | last post by:
Hello, I need some DETAILED help. I'm trying to download a java game off the internet but an error window pops up which says "Java Virtual Machine, Fail to load Main-Class manifest attribute from...
6
by: hemantkumar | last post by:
hii i am new to ASP.NET 2.0.and i m building an application in Vb.Net.I have placed my database connection setting in application web.config file.And when i want to use Configurationmanager class...
0
by: =?Utf-8?B?U3JpZGhhcg==?= | last post by:
Hi, Usually in Visual studio 2003 when we include a crystal report it creates a class file for that report. And we will use that class to dynamically load the data. But I am not able to find...
3
by: Jacob | last post by:
Hi! Where do i find .NET class libary in Visual studio? I mean if you would like to browse through the classes and members. Or if you want to search fr specific classes or members. Thanks in...
5
by: Ohad weiss | last post by:
Hi all, I have a class in project A. At the same solution, I have another project - named project B. I want to write a piece of code in that class from project B that finds the class in...
3
by: miss peaches | last post by:
I am currently enrolled in a Java Programming Class in which we were asked to create a Class to store and retrieve an employee's name, hourly rate, and hours worked. Use constructors to initialize...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.