aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Exception in thread main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Exception in thread main" Watch "Exception in thread main" New topic
Author

Exception in thread main

renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
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!!


Cheers,
Richard
Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
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

Joined: Oct 06, 2008
Posts: 116
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

Joined: Oct 07, 2008
Posts: 82
    
    1
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

Joined: Oct 06, 2008
Posts: 116
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

Joined: Oct 13, 2005
Posts: 39396
    
  28
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

Joined: Oct 13, 2005
Posts: 39396
    
  28
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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Exception in thread main