The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

you are executing the class incorrectly....

Posted by PAwan Garg on September 11, 2000 at 12:32 PM

Have you tried this solution?

Tell me, when a package is compiled, does it not create a separate .CLASS file for each Class within the package? OR does it create only one .CLASS file for the entire package.

If the 2nd is true then the solution suggested is true because you will have to resolve the class by giving the package name also.

And if the first is the case then the CLASSPATH will have to be appended to include the path of the package in it (explicitly).

Pawan

> when you try to run "c:\com\sss\frm>java Slate", your java runtime environment thinks you are trying to invoke the class "Slate.class" instead of "com.sss.frm.Slate.class".

> If you run:
> java com.sss.frm.Slate
> your class should run.

>
> > Please Help. I am exhausted
> > ----------------------------
> > path=%PATH%;c:\jdk\bin;
> > Environmantal variable SET CLASSPATH=.;c:;

> > c:\>java -version
> > java version"1.2"
> > classic VM(build JDK 1.2-v, native threads)

> >
> > package com.sss.frm;
> > import javax.swing.*;
> > import java.awt.*;
> > import java.awt.event.*;
> > class Slate extends Jframe{.................................}

> > c:\com\sss\frm> javac Myframe.java
> > (my compiled class is in dir c:\com\sss\frm)

> > c:\> java Slate
> > Exception in thread "main" java.langNoClassDefFoundError: Slate

> >
> > c:\com\sss\frm>java Slate
> > Exception in thread "main" java.langNoClassDefFoundError(wrong name: com/sss/frm/Slate)
> > at java.lang.ClassLoader.defineClass0(Native Method);
> > at java.lang.ClassLoader.defineClass(ClassLoader.java:403)
> > at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:101)
> > ..........................................................................
> > ..........................................................................

> >
> > If the package definition is made into a comment (blocked) and then compiled.
> > The class executes as desired in its own directory.
> >
> > I cannot gather where I am erring.

> > Yours samant S.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us