Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2004, 01:44 PM
Registered User
Join Date: Jun 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch8 problem

i have 2 files User.java and ArrayListDemo.java
i complie the two file(javac *.java)

then, i type java ArrayListDemo
there is an error
please tell me why

C:\jakarta-tomcat-4.1.12\webapps\ch8\WEB-INF\classes\com\wrox\utilities>java Arr
Exception in thread "main" java.lang.NoClassDefFoundError: ArrayListDemo (wrong
name: com/wrox/utilities/ArrayListDemo)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java :509)
        at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:12
        at java.net.URLClassLoader.defineClass(URLClassLoader .java:246)
        at java.net.URLClassLoader.access$100(URLClassLoader. java:54)
        at java.net.URLClassLoader$1.run(URLClassLoader.java: 193)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.j ava:186)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:265)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:2 62)
        at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:322)

***********************here is my code***************************
package com.wrox.utilities;

public class User {

    String username;
    String phonenumber;

    public User() {}

    public User(String uname, String pnum) {
        username = uname;
        phonenumber = pnum;

    void setUsername(String uname) {
        this.username = uname;

    String getUsername() {
        return username;

    void setPhonenumber(String pnum) {
        this.phonenumber = pnum;

    String getPhonenumber() {
        return phonenumber;

package com.wrox.utilities;
import java.util.ArrayList;

public class ArrayListDemo {
    public static void main(String[] args) {
        User usr1 = new User("Joanne Yu", "0968000669");
        User usr2 = new User("Elaine Tsai", "0968469933");
        User usr3 = new User("Ogg", "0925");

        ArrayList userlist = new ArrayList();

        User usr = (User) userlist.get(1);

        for(int i=0;i<userlist.size();i++) {
            usr = (User) userlist.get(i);


Reply With Quote
  #2 (permalink)  
Old June 22nd, 2004, 02:25 AM
Registered User
Join Date: May 2004
Location: Peshawar, NWFP, Pakistan.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAK_NUST Send a message via Yahoo to MAK_NUST

This exception often occur when you souldon't define your package in your classpath. So check you class path. and then tell me if it work.

Mohammad Asif Khan
Niit Distributive Computing Research group
Nust Institute of Information Technology
Email: asif_khan@ieee.org
Reply With Quote
  #3 (permalink)  
Old June 22nd, 2004, 05:30 AM
Registered User
Join Date: Jun 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

it can be work when i type
java com.wrox.utilities.ArrayListDemo
java ArrayListDemo
still has error

i checked my classpath many times
.;C:\j2sdk1.4.0_02\lib;C:\j2sdk1.4.0_02\lib\tools. jar;C:\jakarta-tomcat-4.1.12\common\lib;C:\jakarta-tomcat-4.1.12\common\lib\servlet.jar;

Reply With Quote
  #4 (permalink)  
Old July 19th, 2004, 02:40 AM
Registered User
Join Date: Jul 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

add the user.class in the current classpath and then run....gennerally it looks for user.java and since it doesnt find that class it raises exception..........

Try this way...may be it should work
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CH8 Hyperlink Extractor Service link for wsdl Firmbyte BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 May 18th, 2008 05:26 AM
MySQL conversions - ch8 - Database Abstraction binne BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 1 December 10th, 2007 11:56 PM
Ch8 - TIO#4 (Other List Controls) jecii BOOK: Beginning ASP.NET 2.0 and Databases 0 December 7th, 2007 07:57 PM
Ch8 DB_Migration_Utility robodent BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 December 5th, 2006 07:47 PM
Ch8 pg 266 wadesmart BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 15 November 28th, 2003 03:33 PM

All times are GMT -4. The time now is 01:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.