Closed. This question needs
CodePudding user response:
- It seems there is no
jaba
directory which is needed to represent package jaba
So, there are two options:
- create a directory
jaba
and move class jau.java
into it.
C:\dell\Documents\Java attack>tree /f
C:.
└───jaba
jau.java
C:\dell\Documents\Java attack>
- OR edit
jau.java
source file to remove package jaba;
statement
- To compile the sources, use
javac
command with -d classes
to specify the directory where compiled class(es) should be placed
C:\dell\Documents\Java attack>javac -d classes jaba/jau.java
C:\dell\Documents\Java attack>tree /f
C:.
├───classes
│ └───jaba
│ jau.class
│
└───jaba
jau.java
- To run the compiled class placed in
classes
directory, the classpath needs to be provided using -cp
option and a fully qualified class name (including package):
C:\dell\Documents\Java attack>java -cp classes jaba.jau
I am java of class jau
If the package is removed (assuming the file is renamed to jau2.java
), it should be compiled and run as follows:
C:\dell\Documents\Java attack>tree /f
C:.
jau2.java
No subdirectories
C:\dell\Documents\Java attack>javac -d classes jau2.java
C:\dell\Documents\Java attack>tree /f
C:.
│ jau2.java
│
└───classes
jau2.class
C:\dell\Documents\Java attack>java -cp classes jau2
I am java of class jau2