Exception in thread "main" java.lang.NoClassDefFoundError:

F

Froggy

Alright, I am new to Java, and I am having some major issues with it.
I am writing a servlet that will tinker with excel files, so I grabbed
the jexcelapi package (http://www.andykhan.com/jexcelapi/), and tried
to use. To no avail.
through the servlet, it ran the following error:

******************************************************
Error: 500
Internal Servlet Error:

java.lang.NoClassDefFoundError: jxl/read/biff/BiffException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.web.core.ServletWrapper.loadServlet(ServletWrapper.java:90)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:109)
at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
at com.sun.web.core.Context.handleRequest(Context.java:375)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:135)
******************************************************

So, thinking that I might have screwed things up, I tried first to
compile the demo ReadWrite.java file, then I ran the precompiled file
ReadWrite.class. Both of them resulted in the following error:

Exception in thread "main" java.lang.NoClassDefFoundError:
ReadWrite/class

I am pretty certain that the person who developed this knows a lot
more about Java than me, and therefore that this thing should work.
Now what stupid thing am I (not) doing?

BTW: win32, using the jsdk 2.1 and j2eesdk1.4
I installed j2eeesdk1.4, then extracted the jsdk 2.1 into the base
Java\ directory...


Please help me, I beg you.
 
J

Jeffrey Palm

Froggy said:
Alright, I am new to Java, and I am having some major issues with it.

What is your compilation command?
Exception in thread "main" java.lang.NoClassDefFoundError:
ReadWrite/class

type 'java ReadWrite' not 'java ReadWrite.class'

Jeff
 
J

Jose Rubio

Make sure that the excel api jar file is in the classpath. In a servlet
environment you can put the jar file in the WEB-INF/lib folder of your web
app.

And also try what Jeffrey mentioned about running the demo class without the
..class extension.

Jose
 
F

Froggy

I have been corresponding with Jeffrey and he helped me figure out the
ReadWrite problem (turns out it didnt have a main()...oops)

However, I am still encountering errors with the servlet.
I copied the jxl.jar file to WEB-INF/lib (which I had to create...),
recompiled, and ran the program, but it returned the same error as
before:
java.lang.NoClassDefFoundError: jxl/read/biff/BiffException
my compilation command is:

D:\Java\jsdk\examples\WEB-INF\servlets>javac -classpath
...\lib\jxl.jar;..\..\..\src Monkey.java

Needless to say that Java and I are not best friends as of now...
-Froggy
 
F

Froggy

Alright, the problem definitely resides somewhere between the keyboard
and the chair.

I have a servlet. It works (prints out html tags).
Can I not just import the jxl.*; library (or wahtever the proper term
is) and use data types and functions within doGet()?

Or do I have to create another class, with another contructor and
main(), and then call that from my servlet...?

It just seems like a hell of a lot of extra work.
-Froggy
 
J

Jose Rubio

I assume the JXL is the excel jar file correct?

If so yes, you can import it in the servlet class and use it in the doGet
method. You don't need to have a main() in a servlet type environment. The
servlet container will load the servlet class and invoke the appropriate
doGet() or doPost() when a request comes in.

BTW, what is your implementation in the doPost()?

Jose
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top