• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread main

 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
while running a java file, i am getting the below error

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at com.excel.XMLToExcel.main(XMLToExcel.java:13)

Please help me out in solving this.

Below is how the code looks like :


Line 13 is where the main function is........

Many Thanks!!
 
Bala Gangadhar
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
There is nothing wrong that leads to the compilation error in the code you specified. May be you missed some imports like import java.io.File. Please check. If still you are getting the problem, give the complete code of the class...

Regards,
Bala
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bala,

I am running this in eclipse. While compiling itself it is giving error. I am importing this jar file import org.apache.poi.hssf.usermodel.*;

Complete set of code is available at this location
 
Bala Gangadhar
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File xmlDocument = new File("C:/Documents and Settings/My Documents/Sample/incomestatements.xml");


replace "/" with "\\" and try...

And for your information in eclipse we dont compile the program sepratly. Each time we save the program it is compiled automatically. What you are getting is a runtime exception.
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Bala.

RunTime Exception :

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at com.excel.XMLToExcel.main(XMLToExcel.java:13)

CompileTime Exception :

In eclipse, i am getting red cross symbole in these lines.

import org.apache.poi.hssf.usermodel.*;
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet spreadSheet = wb.createSheet("spreadSheet");
HSSFRow row1 = spreadSheet.createRow(1);
HSSFRow row2 = spreadSheet.createRow(2);

with error message as "cannot be resolved to type".

Jar file : poi-bin-3.2-FINAL-20081019.zip

JDK version : 1.5.0_02
 
Campbell Ritchie
Sheriff
Pie
Posts: 49808
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you run a class in Eclipse, look whether there are any red marks against its name. If so, click the "problems" tab at the bottom of the window, and look at the list of errors.

What happens is that Eclipse will attempt to execute the .class files, and start off by compiling them; if there is a syntax error the execution fails with the "unresolved compilation error" Exception. I think this is a question specific to Eclipse and would sit better on the IDEs forum, so I shall move this thread.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49808
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added that jar to your CLASSPATH? This is how you do it.
  • R-click the name of your project on the left
  • Properties
  • Java Build Path
  • Add external JARs
  • Browse
  • OK OK OK . . .
  • When you deply the finished product as a JAR, remember to add the external JAR to the CLASSPATH in the manifest file, or incorporate it into your own JAR.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic