I am using the Eclipse IDE to program. After following a tutorial on Apache POI:
https://www.youtube.com/watch?v=RsrF2Ku7ad4
I created an executable jar through eclipse and the following steps from the following link: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm
From the menu bar's File menu, select Export.
Expand the Java node and select Runnable JAR file. Click Next.
In the Runnable JAR export wizard Runnable JAR File Specification page, I select the WriteExcel launch configuration to use to create a runnable JAR.
In the Export destination field, I placed it in my Eclipse workspace.
Then I chose package required libraries into generated JAR files.
I then associated JAR files with Java(TM) Platform SE binary in windows. However when I double click it doesn't create an excel file like it does when i run the program in Eclipse. Running the jar file from the comand line doesnt return an error or create the excel file either.
Clearly I did something wrong any help is greatly appreciated.
edit: Code Used is the same as the youtube tutorial:
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
public class WriteExcel {
public static void main(String[] args) throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("FirstExcelSheet");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(0);
cell.setCellValue("1. Cell");
cell = row.createCell(1);
DataFormat format = workbook.createDataFormat();
CellStyle dateStyle = workbook.createCellStyle();
dateStyle.setDataFormat(format.getFormat("dd.mm.yyyy"));
cell.setCellStyle(dateStyle);
cell.setCellValue(new Date());
row.createCell(2).setCellValue("3. Cell");
sheet.autoSizeColumn(1);
workbook.write(new FileOutputStream("excel.xls"));
workbook.close();
}
}