Please help me. I am getting a runtime error.
Package problem in java?
Please help me. I have two packages named app and Util. Util is inside app. In Util i have the file BitUtils.java and in app i have CertkillerApp.java which is the driver file. I am getting error. Please help me.
BitUtils.java :
package Util;
public class BitUtils {
public static void process(new byte[]) {
System.out.println("Inside method byte");
}
}
CertkillerApp.java
package app;
public class CertkillerApp {
public static void main(String[] args) {
byte[] bytes = new byte[256];
Util.BitUtils.process(bytes);
}
}
Now when i am entering app directory inside D: by cd app and compling by javac CertkillerApp.java. It is compiling but when i am executing from the same directory it is
giving runtime errror.
Output :
D:\APP>java app.CertkillerApp
Exception in thread "main" java.lang.NoClassDefFoundError... app/CertkillerApp
[991 byte] By [
Tatona] at [2007-10-3 2:53:48]

Try:java-classpathD:\app.CertkillerAppAnd please read: [url http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/classpath.html]Setting the class path[/url].Regards
Try running the command from D:\ instead of D:\App .Or use "set CLASSPATH = %CLASSPATH%, D:\"
I tried both ways but it is not running.Please help me.
Tatona at 2007-7-14 20:42:52 >

Taton - bringing you the finest in general ineptitude since August 4th 2006
> I tried both ways but it is not running.> Please help me.What exactly are you trying, and maybe you need to make sure that the directory name matches the package name, case 'n all...
I think I got it.
You said: "Util is inside app", right?
First: package names should allways be with lowercases.
So I would change it for: util.
Second: since the package util is "inside" the package app, then the real name of the package util is: app.util.
It is NOT just util (there is no such thing in Java as partial package names).
So you should have the following folders/files:
D:\
D:\app
D:\app\CertkillerApp.java
D:\app\util
D:\app\util\BitUtils.java
Where BitUtils.java file should start with:package app.util;
And CertkillerApp.java should look like:package app;
public class CertkillerApp {
public static void main(String[] args) {
byte[] bytes = new byte[256];
app.util.BitUtils.process(bytes);
}
}
Then you should compile them:cd D:\
javac -classpath . app\*.java app\util\*.java
Then run it:cd D:\
java -classpath . app.CertkillerApp
Regards
Compiling FineD:\>javac -classpath app\*.java app\util\*.javaNot runningD:\>java D:\app app.CertkillerAppException in thread "main" java.lang.NoClassDefFoundError: D:\appRegards TatonMessage was edited by: Taton
Tatona at 2007-7-14 20:42:52 >

> Compiling Fine
>
> D:\>javac -classpath app\*.java app\util\*.java
>
> Not running
> D:\>java D:\app app.CertkillerApp
> Exception in thread "main"
> java.lang.NoClassDefFoundError: D:\app
Notice something? You forgot the -cp flag.
D:\>java -classpath D:\app app.CertkillerAppException in thread "main" java.lang.NoClassDefFoundError: app/CertkillerAppD:\>java -cp D:\app app.CertkillerAppException in thread "main" java.lang.NoClassDefFoundError: app/CertkillerAppRegardsTaton
Tatona at 2007-7-14 20:42:52 >

Taton,I must say. Your inability to follow simple instructions is quite remarkable. Do look at what you are doing and what jfbriere has told you several times now. Do you see a difference? Please god see a difference...
Done. denotes current directory.Thanks all.
Tatona at 2007-7-14 20:42:52 >

I always have this classpath problem.
Tatona at 2007-7-14 20:42:52 >

Here's some info on classpath:
[url=http://wiki.java.net/bin/view/Javapedia/ClassPath ]Javapedia: Classpath[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html ]How Classes are Found[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html ]Setting the class path (Windows)[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html ]Setting the class path (Solaris/Linux)[/url]
[url=http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html ]Understanding the Java ClassLoader[/url]