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);
}
}
Output :
D:\APP>javac CertkillerApp.java
.\Util\BitUtils.java:4: illegal start of type
public static void process(new byte[]) {
^
.\Util\BitUtils.java:8: <identifier> expected
}
^
.\Util\BitUtils.java:4: missing method body, or declare abstract
public static void process(new byte[]) {
^
3 errors
Please help me. Don't take it as homework.
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
Solved it.
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);
}
}
Output :
D:\APP>javac CertkillerApp.java
.\Util\BitUtils.java:4: illegal start of type
public static void process(new byte[]) {
^
.\Util\BitUtils.java:8: <identifier> expected
}
^
.\Util\BitUtils.java:4: missing method body, or declare abstract
public static void process(new byte[]) {
^
3 errors
Please help me. Don't take it as homework.
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
Solved it.
package Util;
class BitUtils
{
public static void process(byte[]nn)
{
System.out.println("Inside method byte");
}
}
class CertkillerApp
{
public static void main(String[] args) {
byte[] bytes = new byte[256];
Util.BitUtils.process(bytes);
}
}
class BitUtils
{
public static void process(byte[]nn)
{
System.out.println("Inside method byte");
}
}
class CertkillerApp
{
public static void main(String[] args) {
byte[] bytes = new byte[256];
Util.BitUtils.process(bytes);
}
}
either add
import app.util.bitutils
or
change
Util.BitUtils.process(bytes) ---> this as
app.util.bitutils.process
import app.util.bitutils
or
change
Util.BitUtils.process(bytes) ---> this as
app.util.bitutils.process
package Util;
class BitUtils
{
public static void process(byte[]nn)
{
System.out.println("Inside method byte");
}
}
class CertkillerApp
{
public static void main(String[] args) {
byte[] bytes = new byte[256];
Util.BitUtils.process(bytes);
}
}
class BitUtils
{
public static void process(byte[]nn)
{
System.out.println("Inside method byte");
}
}
class CertkillerApp
{
public static void main(String[] args) {
byte[] bytes = new byte[256];
Util.BitUtils.process(bytes);
}
}
I think u need to declare package as
package app.util;
and when u r using the process method u need to import the package like this
import app.util.*;
and use the method as BitUtils.process();
i think this wil work fine.
package app.util;
and when u r using the process method u need to import the package like this
import app.util.*;
and use the method as BitUtils.process();
i think this wil work fine.
redownload your java