wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes the error in using myself created package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "the error in using myself created package" Watch "the error in using myself created package" New topic

the error in using myself created package


Joined: Feb 19, 2002
Posts: 2
I try to create my own package and use a class from that package in a program. I used two snippets of code from textbook, which I think the codes themselves are correct.
The first code:
package com.deitel.jhtp3.ch08;
import java.text.DecimalFormat; // used for number formatting
// This class maintains the time in 24-hour format
public class Time1 extends Object {
private int hour; // 0 - 23
private int minute; // 0 - 59
private int second; // 0 – 59
The second code:
import javax.swing.JOptionPane;
import com.deitel.jhtp3.ch08.Time1; // import Time1 class
public class TimeTest {
public static void main( String args[] )
Step 1:
I compile the first by typing “ javac –d c:\jdk1.3.1_01\jre\classes Time1.java ” in command window, everything is going very well , and Time1.class file was placed in c:\jdk1.3.1_01\jre\classes\ com\deitel\jhtp3\ch08.
I compile the second by typing “ javac TimeTest.java ”, it is going well until now.
I run it using “java TimeTest ” , here does occur error message, which I don’t know where I m wrong.
E:\9024\test1>java TimeTest
Exception in thread "main" java.lang.NoClassDefFoundError: com/deitel/jhtp3/ch08/Time1

is there anyone who has idea about my errors?

Exception in thread "main" java.lang.NoClassDefFoundError: com/deitel/jhtp3/ch08/Time1
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Before using package try to learn more about classpath. In your case use the following in your command prompt.
set classpath=%classpath%;c:\jdk1.3.1_01\jre\classes;.;
then run your programm it will work.

Sharing is learning
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please re-register under an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

I agree. Here's the link: http://aspose.com/file-tools
subject: the error in using myself created package
Similar Threads
abstract classes and inhereitance
Java help!!!!
how to compute time?
abstract class
need help on exception of "org/xml/sax/SAXException"