java.lang.NoClassDefFoundError Please Help
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 3
- Joined: Thu Dec 04, 2003 6:56 pm
java.lang.NoClassDefFoundError Please Help
im using the java web devlopers pack 1.3
installed in ;
C:\jwsdp-1.3
when i run certain classes (when there name is no long see below for example i get the error)
java.lang.NoClassDefFoundError
==============================================
the problem is basically a class called Test will run while a class (identical codewise) called TestCustomerDao Wont run given the above error (it compiles fine)
sample class which wont run(code wise this is no problem)
======================================
// CustomerByNameCommand.java
/*
6 - dec - 03
note to myself
proble with this class
it doesnt work because the class name is too long?
the code is fine
*/
package web.proj3.command ;
import java.util.* ;
import java.sql.* ;
import java.io.* ;
/*
CustomerByNameCommand
Q4 (ii)
*/
import javax.servlet.* ;
import javax.servlet.http.* ;
import web.proj3.business.* ;
import web.proj3.dao.* ;
import web.proj3.exceptions.* ;
public class CustomerByNameCommand implements Command
{
private HttpServletRequest request ;
private HttpServletResponse response ;
private HttpSession session ;
public CustomerByNameCommand(HttpServletRequest aRequest,
HttpServletResponse aResponse,
HttpSession aSession)
{
request = aRequest ;
response = aResponse ;
session = aSession ;
}
public String execute()
{
String page = null ;
CustomerDao dao = new CustomerDao() ;
try
{
//has to be changed
String customerName = request.getParameter("customerName") ;
ArrayList customers = dao.getCustomersByName(customerName);
/*String customerName = request.getParameter("customerName") ;
ArrayList customers = dao.getCustomersByName(customerName) ;
if (customers.size() == 0)
{
request.setAttribute("errorMessage", "No customers with this name") ;
page = errorPage ;
}
else
{
request.setAttribute("customers", customers) ;
page = "/" + request.getParameter("command") + ".jsp" ; // i.e. /CustomersByName.jsp
}*/
if (customers.size() == 0)
{
request.setAttribute("errorMessage", NO_CUSTOMERS) ;
page = errorPage ;
}
else
{
request.setAttribute("customers", customers) ;
page = "/" + request.getParameter("command") + ".jsp" ; // i.e. /Customers.jsp
}
}
catch(DaoException e)
{
page = errorPage ;
request.setAttribute("errorMessage", e.getMessage() ) ;
}
return page ;
}
}
installed in ;
C:\jwsdp-1.3
when i run certain classes (when there name is no long see below for example i get the error)
java.lang.NoClassDefFoundError
==============================================
the problem is basically a class called Test will run while a class (identical codewise) called TestCustomerDao Wont run given the above error (it compiles fine)
sample class which wont run(code wise this is no problem)
======================================
// CustomerByNameCommand.java
/*
6 - dec - 03
note to myself
proble with this class
it doesnt work because the class name is too long?
the code is fine
*/
package web.proj3.command ;
import java.util.* ;
import java.sql.* ;
import java.io.* ;
/*
CustomerByNameCommand
Q4 (ii)
*/
import javax.servlet.* ;
import javax.servlet.http.* ;
import web.proj3.business.* ;
import web.proj3.dao.* ;
import web.proj3.exceptions.* ;
public class CustomerByNameCommand implements Command
{
private HttpServletRequest request ;
private HttpServletResponse response ;
private HttpSession session ;
public CustomerByNameCommand(HttpServletRequest aRequest,
HttpServletResponse aResponse,
HttpSession aSession)
{
request = aRequest ;
response = aResponse ;
session = aSession ;
}
public String execute()
{
String page = null ;
CustomerDao dao = new CustomerDao() ;
try
{
//has to be changed
String customerName = request.getParameter("customerName") ;
ArrayList customers = dao.getCustomersByName(customerName);
/*String customerName = request.getParameter("customerName") ;
ArrayList customers = dao.getCustomersByName(customerName) ;
if (customers.size() == 0)
{
request.setAttribute("errorMessage", "No customers with this name") ;
page = errorPage ;
}
else
{
request.setAttribute("customers", customers) ;
page = "/" + request.getParameter("command") + ".jsp" ; // i.e. /CustomersByName.jsp
}*/
if (customers.size() == 0)
{
request.setAttribute("errorMessage", NO_CUSTOMERS) ;
page = errorPage ;
}
else
{
request.setAttribute("customers", customers) ;
page = "/" + request.getParameter("command") + ".jsp" ; // i.e. /Customers.jsp
}
}
catch(DaoException e)
{
page = errorPage ;
request.setAttribute("errorMessage", e.getMessage() ) ;
}
return page ;
}
}
-
- Posts: 3
- Joined: Thu Dec 04, 2003 6:56 pm
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
A dot actually stands for the current directory. So it would seem that your current directory must not have been in your path.as i added a dot to my classpath
Two dots is the parent directory of the current (referenced) directory.
Example: cd..\..\.. will go up three levels in the directory structure.
(Guess I should use folders vs. directories today?)
Hope this was helpful.............good luck,
Bob
Bob
I'm having this same problem. It keeps saying
"Exception in thread "main" java.lang.NoClassDefFoundError: Coins2
Press any key to continue . . ."
but I've added the "." in my classpath "c:\jdk1_4_2\bin\Toni\."
Is there anything else I'm doing wrong? The name (as you see above) is Coins2, so I know it's not the length of the name.
"Exception in thread "main" java.lang.NoClassDefFoundError: Coins2
Press any key to continue . . ."
but I've added the "." in my classpath "c:\jdk1_4_2\bin\Toni\."
Is there anything else I'm doing wrong? The name (as you see above) is Coins2, so I know it's not the length of the name.
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
What's your operating system?
For WinXP you can right click on My Computer, select "Properties",
select the "Advanced" tab, click "Environment Variables", under "System
variables" look for "classpath", create one if it does not exist. HTH
For WinXP you can right click on My Computer, select "Properties",
select the "Advanced" tab, click "Environment Variables", under "System
variables" look for "classpath", create one if it does not exist. HTH
Then I open up and see
the person fumbling here is me
a different way to be
the person fumbling here is me
a different way to be
Enviromental Variables?
Can someone please explain this to me, Please. I am getting the same error and have put in the suggested variable with no luck. I am working on a machine with WinXP professional it is home networked with another computer but I am the adminstrater. Would love to get this bug fixed soon Thanks in advanced for any help
Since java 1.1 everything works fine without an explicitly set CLASSPATH, if everything else is set up correctly. After the sdk installation you should (and I don't know why the installer script doesn't do that automagically) create an environment variable named JAVA_HOME pointing to the installation directory, and add $JAVA_HOME/bin to the command path. There's no need to create a CLASSPATH variable, and creating one may screw things up (for example forgetting to add current dir to it...)
Setting things up that way always worked flawlessly for me.
All the gory details about CLASSPATH and how the compiler/runtime go looking for classes are in the documentation, available both online and for download.
Hope that helps.
Setting things up that way always worked flawlessly for me.
All the gory details about CLASSPATH and how the compiler/runtime go looking for classes are in the documentation, available both online and for download.
Hope that helps.
Thanks for responding
My problem was I had a conflicting program that I had to delete. Does anyone have a quick fix for running textpad with Visual Studio 6.0?
I'm having the same problem. I've already set up
CLASSPATH "c:\j2sdk1.4.1_06\bin\;." under the system enviroment on XP Pro. I finally got it compile by changing ther compile parameters but I can't figure out how to get this to run.
java sdk is installed under c:\ and my file are under d:\javaexamples\
Please help.
CLASSPATH "c:\j2sdk1.4.1_06\bin\;." under the system enviroment on XP Pro. I finally got it compile by changing ther compile parameters but I can't figure out how to get this to run.
java sdk is installed under c:\ and my file are under d:\javaexamples\
Please help.
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
Your best start is the Java FAQ.
According to agnul above you don't need to do this, the classpath thing. What version of TP are you using? The current version is 4.7.2. Try opening a command window and entering "java -version" to see if it's accessible on your system. On my system under the tool "Run Java Application" I have Parameters=$BaseName and Initial Folder=$FileDir. If you are already using version 4.7.2 of TP try removing your Java tools and adding them again, without the classpath variable, and as a last resort you can uninstall/reinstall TP. HTH
According to agnul above you don't need to do this, the classpath thing. What version of TP are you using? The current version is 4.7.2. Try opening a command window and entering "java -version" to see if it's accessible on your system. On my system under the tool "Run Java Application" I have Parameters=$BaseName and Initial Folder=$FileDir. If you are already using version 4.7.2 of TP try removing your Java tools and adding them again, without the classpath variable, and as a last resort you can uninstall/reinstall TP. HTH
Then I open up and see
the person fumbling here is me
a different way to be
the person fumbling here is me
a different way to be