Problem with Excelapi: Error: package jxl does not exist
I've:
1)added the the excelapi subdirectory that contains the jar file to the system class path, then I tried explicitly adding the jxl.jar file to the classpath (below)
c:\Program Files\Java\jdk1.7.0_02\bin\; c:\Program Files\Java\jexcelapi\jxl.jar;
2)I tried adding a copy of the jxl.jar file to the java\jdk1.7.0_02\bin\ subdirectory also.
I still get the same error msg, i.e, jxl does not exist.
Anyone have any other troubleshooting ideas?
Thanks,
Rob
Re: Problem with Excelapi: Error: package jxl does not exist
Did you code the import statement correctly?
Re: Problem with Excelapi: Error: package jxl does not exist
//I tried the following:
import jxl.*;
//and explicitly
import jxl.jar;
Re: Problem with Excelapi: Error: package jxl does not exist
You could include the jar in your classpath, EG if you were on a windows and your username was "Rob" and you saved your file at:
C:\Users\Rob\Java\JXLTest.java
And the jxl.jar at
C:\Users\Rob\Java\resources\jxl.jar
to run the program, you would use
To compile:
javac -classpath .\resources\* JXLTest.java
To run:
java -classpath .\resources\* JXLTest
Re: Problem with Excelapi: Error: package jxl does not exist
//I attempted the above but still no luck - the following is the code:
import jxl.jar;
public class JXLTest
{
public static void main(String[] args)
{
System.out.println("Test Successful: JXL was imported");
}
}
//the following is the compile error:
1 error found:
File: F:\java\JXLTest.java [line: 2]
Error: F:\java\JXLTest.java:2: package jxl does not exist
\\the following is an excerpt from the classpath:
;C:\jdk1.6.0_31\lib;C:\jexcelapi\jxl.jar;
Re: Problem with Excelapi: Error: package jxl does not exist
Is that the package name? jxl.jar?
It looks like a filename.
Try using the javac -cp option on the command line to specify the classpath.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Re: Problem with Excelapi: Error: package jxl does not exist
I followed your instructions - I think: Below is the screen copy from command prompt
I:\Java>javac -cp jxl.jar ExcelDemo.java
ExcelDemo.java:3: error: package jxl does not exist
import jxl.jar;
^
1 error
.................................................. .................................................. ........
Below is what I'm trying to accomplish - to import a jar file that will enable me to read/write from java to Excel. It is the instructions from the Excelapi website. If there's an easier way, please let me know. Thanks for your patience - Rob
JExcelApi can read an Excel spreadsheet from a file stored on the local filesystem or from some input stream. The first step when reading a spreadsheet from a file or input stream is to create a Workbook. The code fragment below illustrates creating a workbook from a file on the local filesystem.
import java.io.File;
import java.util.Date;
import jxl.*;
...
Workbook workbook = Workbook.getWorkbook(new File("myfile.xls"));
Re: Problem with Excelapi: Error: package jxl does not exist
Quote:
javac -cp jxl.jar ExcelDemo.java
was the jxl.jar file in the same folder with the ExcelDemo.java file? That's the what the above expects.
If not, you need to tell the javac program where to find it by providing a path.
Re: Problem with Excelapi: Error: package jxl does not exist
ok I copied the jxl.jar file into the same folder as ExcelDemo.java
Different error but essentially the same result:
I:\Java>javac -cp jxl.jar ExcelDemo.java
ExcelDemo.java:3: error: cannot find symbol
import jxl.jar;
^
symbol: class jar
location: package jxl
1 error
Re: Problem with Excelapi: Error: package jxl does not exist
Is that the name of the package? It looks like the name of a file.
what happened to this:
import jxl.*;
Re: Problem with Excelapi: Error: package jxl does not exist
That was it now it works! - in Command Prompt
When I try to compile in Dr.Java I still get the same error but I guess that's because I'm using the statement:
import jxl.*;
is it possible to translate the specification of the classpath into dr.java?
The below is the error when running in Dr.Java:
1 error found:
File: I:\Java\ExcelDemo.java [line: 3]
Error: package jxl does not exist
Re: Problem with Excelapi: Error: package jxl does not exist
Quote:
now it works! - in Command Prompt
Ok now you see what needs to be where to compile your program.
You need to find someone that can help you configure the IDE you are trying to use.
Re: Problem with Excelapi: Error: package jxl does not exist
Thanks much for all your help ... and patience!
Re: Problem with Excelapi: Error: package jxl does not exist
You're welcome. Good luck.