Results 1 to 4 of 4
Thread: java.lang.ClassNotFoundException
- 11-19-2012, 06:43 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
java.lang.ClassNotFoundException
I am currently working through the book "Sams Teach yourself Java 6 in 21 days" and am on Day 6. Today's lesson is about using packages. I have created a Storefront application consisting of two classes -Storefront and Item. These classes are organized in a package, org.im.ecommerce.
I have set the CLASSPATH variable as .;c:\Program Files\java\jdk1.6.0_01\lib\tools.jar;c:\dev\java
The Storefront.class and Item.class files are in the c:\dev\java\org\im\ecommerce folder.
I have a second application called GiftShop that uses the aforementioned classes. This application compiles successfully but when I try to execute it, we get the java.lang.ClassNotFoundException
Here is a snippet of code from each file.
GiftShop.java
import org.im.ecommerce.*;
public class GiftShop {
public static void main(String[] arguments) {
Storefront store = new Storefront();
//body of program
}
Storefront.java
package org.im.ecommerce;
import java.util.*;
public class Storefront {
//body of program
}
Item.java
package org.im.ecommerce;
import java.util.*;
public class Item implements Comparable {
//body of program
}
This is direct from the console.
%PROGRAMFILES%\jEdit> java -classpath "$CLASSPATH;C:\Users\Oscar\Documents\workspace " -ms32m -mx32m GiftShop
Exception in thread "main" java.lang.NoClassDefFoundError: org/im/ecommerce/Storefront
at GiftShop.main(GiftShop.java:6)
Process java exited with code 1
What else can I be looking at? Your help is greatly appreciated.
- 11-19-2012, 07:18 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 698
- Rep Power
- 6
Re: java.lang.ClassNotFoundException
If you are using Windows to access an environment variable from the terminal use %VARIABLE_NAME% not $VARIABLE_NAME. In your case the get the CLASSPATH variable you should %CLASSPATH%.
Website: Learn Java by Examples
- 11-19-2012, 07:51 AM #3
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
Re: java.lang.ClassNotFoundException
It's working now. thanks
- 11-19-2012, 11:01 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
java.lang.ClassNotFoundException - Issue
By C.phantasy in forum New To JavaReplies: 3Last Post: 11-05-2012, 04:58 AM -
java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
By newbie8412 in forum Apache CommonsReplies: 0Last Post: 03-12-2012, 01:13 PM -
java.lang.ClassNotFoundException
By djgovins in forum Java ServletReplies: 4Last Post: 07-25-2011, 11:54 AM -
java.lang.ClassNotFoundException: com.sun.star.lang.XEventListener
By Leroy in forum Advanced JavaReplies: 8Last Post: 11-04-2010, 01:46 PM -
java.lang.ClassNotFoundException
By ravian in forum New To JavaReplies: 1Last Post: 01-07-2008, 10:31 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks