双击之后老是出现:could not find the main class. Program will exit.其它程序打包都没有问题,就单单这一个出现问题,我不知道是为什么,麻烦各位高手指点,我也手工打包过,还是不行,程序如下:package yuebao;import java.io.*;
import java.text.*;import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;public class CallRecord
{
public static void main(String[] args)
{
int b=0;
POIFSFileSystem pfs=null;
HSSFWorkbook hwb=null;
try
{
pfs=new POIFSFileSystem(new FileInputStream("CallRecord(Running).xls"));
hwb=new HSSFWorkbook(pfs);
HSSFSheet sheet=hwb.getSheetAt(0);
int rowNum;
int i;
String[] date=new String[3100];
double[] record=new double[3100];
double[] percent=new double[3100];
rowNum = sheet.getLastRowNum();
//System.out.println(rowNum);
for (i = 4; i <= rowNum; i++) {
//System.out.println(sheet.getRow(i).getCell((short)0).getDateCellValue().toLocaleString());
date[i]=sheet.getRow(i).getCell((short)0).getDateCellValue().toLocaleString();
HSSFCell cl=sheet.getRow(i).getCell((short)1);
record[i]=Double.parseDouble(cl.toString().trim());
HSSFCell c2=sheet.getRow(i).getCell((short)2);
percent[i]=Double.parseDouble(c2.toString().trim());
//System.out.println(i+"---"+date[i]+"---"+record[i]+"---"+percent[i]);
}
HSSFWorkbook wb=new HSSFWorkbook();
FileOutputStream fo=new FileOutputStream("callRecord.xls");
HSSFSheet ht=wb.createSheet("彩铃月报");
HSSFRow r1 = ht.createRow((short)0);
HSSFCell c1 = r1.createCell((short)0);
c1=r1.getCell((short)0);
c1.setCellValue("日期1");
HSSFCell c2 = r1.createCell((short)1);
c2=r1.getCell((short)1);
c2.setCellValue("日期2");
HSSFCell c3 = r1.createCell((short)2);
c3=r1.getCell((short)2);
c3.setCellValue("忙时试呼次数");
HSSFCell c4 = r1.createCell((short)3);
c4=r1.getCell((short)3);
c4.setCellValue("忙时应答率");
double[] result1=new double[93];
int start=4;
int end=96;
int n=0;
for(int j=start;j<=end;j++)
{
int m=n++;
result1[m]=0;
//System.out.println(m);
for(int k=0;k<4;k++)
{
result1[m]=result1[m]+record[j+k];
}
//System.out.println("result1["+m+"]:"+result1[m]);
//System.out.println("j:"+j);
if((end-j)==0)
{
b++;
float max=(float)result1[0];
float per=(float)0;
int l1=0;
for(int l=1;l<result1.length;l++)
{
if(max<result1[l])
{
max=(float)result1[l];
l1=l;
}
}
for(int t=0;t<4;t++)
{
per=(float)(per+percent[96*((j/96)-1)+4+l1+t]);
//System.out.println(date[96*((j/96)-1)+4+l1+t]+"---"+record[96*((j/96)-1)+4+l1+t]+"---"+percent[96*((j/96)-1)+4+l1+t]);
}
DecimalFormat df=new DecimalFormat("##.00");
//System.out.println("max-----"+max+"per:"+df.format(per*100/4));
if(end+3<=rowNum){
HSSFRow r2 = ht.createRow((short)b);
HSSFCell hc1 = r2.createCell((short)0);
hc1=r2.getCell((short)0);
hc1.setCellValue(date[96*((j/96)-1)+4+l1]);
HSSFCell hc2 = r2.createCell((short)1);
hc2=r2.getCell((short)1);
String[] s=date[96*((j/96)-1)+4+l1].split(" ");
hc2.setCellValue(s[0]);
HSSFCell hc3 = r2.createCell((short)2);
hc3=r2.getCell((short)2);
hc3.setCellValue(max);
HSSFCell hc4 = r2.createCell((short)3);
hc4=r2.getCell((short)3);
hc4.setCellValue(df.format(per*100/4)+"%");
end=j+96;
}
else
{
break;
}
j=j+3;
//System.out.println("come in");
n=0;
}
}
wb.write(fo);
fo.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
import java.text.*;import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;public class CallRecord
{
public static void main(String[] args)
{
int b=0;
POIFSFileSystem pfs=null;
HSSFWorkbook hwb=null;
try
{
pfs=new POIFSFileSystem(new FileInputStream("CallRecord(Running).xls"));
hwb=new HSSFWorkbook(pfs);
HSSFSheet sheet=hwb.getSheetAt(0);
int rowNum;
int i;
String[] date=new String[3100];
double[] record=new double[3100];
double[] percent=new double[3100];
rowNum = sheet.getLastRowNum();
//System.out.println(rowNum);
for (i = 4; i <= rowNum; i++) {
//System.out.println(sheet.getRow(i).getCell((short)0).getDateCellValue().toLocaleString());
date[i]=sheet.getRow(i).getCell((short)0).getDateCellValue().toLocaleString();
HSSFCell cl=sheet.getRow(i).getCell((short)1);
record[i]=Double.parseDouble(cl.toString().trim());
HSSFCell c2=sheet.getRow(i).getCell((short)2);
percent[i]=Double.parseDouble(c2.toString().trim());
//System.out.println(i+"---"+date[i]+"---"+record[i]+"---"+percent[i]);
}
HSSFWorkbook wb=new HSSFWorkbook();
FileOutputStream fo=new FileOutputStream("callRecord.xls");
HSSFSheet ht=wb.createSheet("彩铃月报");
HSSFRow r1 = ht.createRow((short)0);
HSSFCell c1 = r1.createCell((short)0);
c1=r1.getCell((short)0);
c1.setCellValue("日期1");
HSSFCell c2 = r1.createCell((short)1);
c2=r1.getCell((short)1);
c2.setCellValue("日期2");
HSSFCell c3 = r1.createCell((short)2);
c3=r1.getCell((short)2);
c3.setCellValue("忙时试呼次数");
HSSFCell c4 = r1.createCell((short)3);
c4=r1.getCell((short)3);
c4.setCellValue("忙时应答率");
double[] result1=new double[93];
int start=4;
int end=96;
int n=0;
for(int j=start;j<=end;j++)
{
int m=n++;
result1[m]=0;
//System.out.println(m);
for(int k=0;k<4;k++)
{
result1[m]=result1[m]+record[j+k];
}
//System.out.println("result1["+m+"]:"+result1[m]);
//System.out.println("j:"+j);
if((end-j)==0)
{
b++;
float max=(float)result1[0];
float per=(float)0;
int l1=0;
for(int l=1;l<result1.length;l++)
{
if(max<result1[l])
{
max=(float)result1[l];
l1=l;
}
}
for(int t=0;t<4;t++)
{
per=(float)(per+percent[96*((j/96)-1)+4+l1+t]);
//System.out.println(date[96*((j/96)-1)+4+l1+t]+"---"+record[96*((j/96)-1)+4+l1+t]+"---"+percent[96*((j/96)-1)+4+l1+t]);
}
DecimalFormat df=new DecimalFormat("##.00");
//System.out.println("max-----"+max+"per:"+df.format(per*100/4));
if(end+3<=rowNum){
HSSFRow r2 = ht.createRow((short)b);
HSSFCell hc1 = r2.createCell((short)0);
hc1=r2.getCell((short)0);
hc1.setCellValue(date[96*((j/96)-1)+4+l1]);
HSSFCell hc2 = r2.createCell((short)1);
hc2=r2.getCell((short)1);
String[] s=date[96*((j/96)-1)+4+l1].split(" ");
hc2.setCellValue(s[0]);
HSSFCell hc3 = r2.createCell((short)2);
hc3=r2.getCell((short)2);
hc3.setCellValue(max);
HSSFCell hc4 = r2.createCell((short)3);
hc4=r2.getCell((short)3);
hc4.setCellValue(df.format(per*100/4)+"%");
end=j+96;
}
else
{
break;
}
j=j+3;
//System.out.println("come in");
n=0;
}
}
wb.write(fo);
fo.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
解决方案 »
- 数组的数组--二维数组
- 一道Java面试题之实现复制、删除、剪切文件(文件夹的实现)的snippet,欢迎拍砖
- JTable的问题
- JDK1.5安装界面乱码是怎么回事?
- oscache 在unix下的配置和使用问题(再次发送严重)
- 怎么设置 JTextComponent 中部分 字体的颜色
- 如果希望返回char* 类型数据的函数返回值都遵循同一规则(如果返回值长度为0,就返回null),用什么设计模式?
- 初学java请教:有关聊天程序
- ClassNotFoundException com.sybase.jdbc2.jdbc.SybDriver 是什么问题
- 简单问题求解!!!
- 请教:我在resin下 用jspSmartUpload.jar 进行上传,总是报错?在tomcat下上传都是成功的
- 想要找到JAVA的工作,应该懂些什么?
Created-By: 1.5.0_01 (Sun Microsystems Inc.)
Main-Class: yuebao.CallRecord
Class-Path: lib/poi-3.0-rc4-20070503.jar(写上POI jar的文件名,我这里仅作示例,若还有其他的使用空格分开)建好后,在这个文件下敲几个回车。使用 Eclipse 的 Export 功能,在你按了三次“Next”(JAR Manifest Specification)后,选择 Use existing manifest from workspace,Browse 找到刚才新建的那个文件。按 Finish 结束。找到生成的 jar 文件,与该文件平级建一个 lib(名字与 Class-Path 中的一致)目录,将外置的 jar 包拷进去,再退回上一层,这个 jar 文件就可以运行了。不知道我啰嗦了那么多,明白了吗?
源文件是没有错误的,已经验证
你最好改用绝对路径~
String[] date=new String[3000];
double[] record=new double[3000];
double[] percent=new double[3000];里的3000改成3100后,再翻译,导出jar,然后jar就不能正确运行了,真不知道是怎么一回事
d -2226271756974174256
at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockRead
er.java:100)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSyste
m.java:84)
at yuebao.CallRecord.main(CallRecord.java:18)
产生了以上错误