I am running Netbeans IDE 8.1 on Windows 10 and my application (697 kb) runs fine until the MarketData3.java file grows to 404 kb and one more line of code (even a simple print statement) is added tot he MarketData3.java file. Once coded added, I get the following Exception since the MarketData3.class file is not created on a successful compilation. This Exception occurs in ReadYahooStockPricess.startChart which creates an instance of MarketData3 but the MarketData3.class is not created upon save/compile or at runtime causing the following Exception.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: stockentrygui/MarketData3 at stockentrygui.ReadYahooStockPrices.startChart(ReadYahooStockPrices.java:1141)
The project is large and proprietary so I have included the pertinent code where the Exception occurs since it runs successfully until MarketData3 grows above a specific size. To help understand flow, the application creates a stockentrygui to select a specific stock and then creates an instance of ReadYahooStockPrices (RYSP) to get specific stock price data and thereafter calls its startChart method below stockentrygui.ReadYahooStockPrices.startChart to create an instance of the MarketData3 class, which calculates technical data, followed by an instance of Chart3 to chart prices and technical. Chart3 gets all data it displays (prices and technical analysis data) from MarketData3.
Below is the pertinent ReadYahooStockPrices.startChart method that creates the MarketData3 object (mdata= new MarketData3) for the selected stock followed by creating the Chart3 class instance (c3= new Chart3).
startChart method in ReadYahooStockPrices called by its Constructor.
public void startChart(){
//TechnicalAnalyzer ta;
MarketData3 mdata;
//Charter c;
int range=12;
String startDate=null;
//new MarketData class - send stock, HLC arrays
//ta= new TechnicalAnalyzer(stock,startDate,range,date,data,totalDays);
mdata= new MarketData3 (stock,startDate,range,date,data,totalDays,alert);
//new Chart - send MarketData identifier, stock and fix range
MarketCommentary mc = new MarketCommentary(mdata);
c3 = new Chart3(stock,range,mdata,mc,companyName);
//c3 = new Chart3(stock,range,mdata);
c3. setBackground(Color.white);
//c3.requestFocus();
//create a JFrame to put Chart3 Canvas and market commentary
//JFrame f = new JFrame();
setTitle("Technical Analysis (Press -> arrow to Forward, "+
"<- arrow to Reverse, and up arrow for more options.)");
GridBagLayout layout = new GridBagLayout();
Container c=getContentPane();
c.setLayout(layout);
c.add(c3);
c.add(mc);
pack();
show();
//setVisible(true);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}//end startChart
The project works fine until the MarketData3 java file grows to 404 kb. The added code is in the formula method that is called below in the MarketData3 constructor. So it seems that the MarketData3.class file is not created after save/compile or run causing the above Exception at runtime. This seems be related to file size.
MarketData3 Constructor:
public MarketData3(String stk, String sdate, int r, String date1[], double data1[][], int tDays,TradeAlerts alert)
//throws AccessControlException, SQLException, Exception
//throws Exception
{//Market Data Constructor
super("MARKET TRACKER");
//if MarketData3 initiated form MarketAnalyzer3 or ReadYahooStockPrices (rysp)
stock=stk;//fixed in MarketData3, variable in rysp
startDate=sdate;//start date fixed to 0
range=r;//range fixed to 12
this.alert=alert;//multiple file trade alert
//System.out.println("135 Start MarketData3");
//if MarketData3 (MD3) initiated from ReadYahooStockPrices
if(tDays>0){
//create new arrays
date= new String [tDays];
data= new double[41][tDays];
displayData = new double[41][tDays];
trend= new int[tDays];
trendLT= new int[tDays];
trendTest=new int[7][tDays];
stop12Date= new String[tDays];
stop6Date= new String[tDays];
stop6DateTest=new String[tDays]; //v6 stop test 110809
stop6DateTestRT=new String[2][tDays];
stop48DateTestRT=new String[4][tDays];
stop6CaptureHiDate= new String[tDays];
stop6CaptureLoDate= new String[tDays];
side= new String[tDays];
momSw= new int[tDays];
trade= new String[tDays];
deltaStoch = new double[7][tDays];
dataTest=new double[10][tDays];
//load date
date=date1;
//load H, L, C prices into array
for(int x=0; x<tDays;x++){
data[0][x]=data1[0][x];
data[1][x]=data1[1][x];
data[2][x]=data1[2][x];
}
totalDays=tDays;
}//end tDays>0
Date now=new Date();
DateFormat df=DateFormat.getDateInstance();
System.out.println("MD3 205 Today's date is "+ df.format(now));
System.out.println("MD3 207 Connect to "+stock+" stockprices");
//con=new DBConnection(driver, url).getConnection();
//stmt=con.createStatement();
// store prices and dates in data arrays if MD3 initiates
if(totalDays==0){
//readStockData(); // read from mysql database
try{
if(date[0]==null)
readStockDataFile(); // read from existing csv files
}
catch(Exception e){
System.out.println("readStockData Exeption "+ e.getMessage());
}
}
// Calculate and store indicators in data array
formula();//Rev7
//getStop12();
//Find startCell
startCell = searchDates(date, startDate);
//dateData(0);// Rev4: Store dates - shift=0 initialization
//marketData();//Rev4: Store prices
//getIndicators();//Rev7
//formula();//Rev6: calculate ma, mom, vel
//trendLogic();
System.out.println("Stock Prices Read");
}// end MarketData3 Constructor
Does anyone know why this happens?
Is there an IDE or JRE interpreter size limit when compiling application and creating .class files?
Do you have to break a class into two classes when it grow too large?
Can this be because my formula method in MarketData3 is too large?