I am writting a program with netbeans and create a .jar file. Here is my main class:
public class Test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//try {
// TODO code application logic here
//create an object and execute the function to calculate monthly wage
CalculateMonthlyWage monthlyWage = new CalculateMonthlyWage();
monthlyWage.CalculateDailyWorkingDurationFromCSV();
//round the result to 2 decimal
BigDecimal result1 = round(monthlyWage.getTotalMonthID1(),2);
BigDecimal result2 = round(monthlyWage.getTotalMonthID2(),2);
BigDecimal result3 = round(monthlyWage.getTotalMonthID3(),2);
System.out.println("1, Janet Java, $"+result1);
//create Java swing window
Frame f = new Frame();
JLabel mLabel = new JLabel();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
mLabel.setText(convertToMultiline("Monthly Wage 3/2014"
+"\n1, Janet Java, $"+result1.toString()
+"\n2, Scott Scala, $"+result2.toString()
+"\n3, Larry Lolcode, $"+result3.toString()));
f.add(mLabel);
f.setSize(500, 500);
f.setVisible(true);
}
public static String convertToMultiline(String orig) {
return "<html>" + orig.replaceAll("\n", "<br>");
}
}
This class is the main, which will create a CalculateMonthlyWage class object and then call the CalculateDailyWorkingDurationFromCSV() method. After that it will create a window and display the result.
When I tried running with the IDE, everthing was fine and the java window displayed what I want. But when I clicked the .jar file, nothing happened.
When I try to run it from the command line using java -jar jarname.jar
, I get the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant
What am I doing wrong here?
EDIT
I downloaded Eclipse, created a new project and copy my source code to it. Everything is fine now. Still I dont understand what's wrong with Netbeans