• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread main

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 157
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tilak
Ranch Hand
Posts: 157
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic