I'm trying to use a class that I've created that is within a java archieve, this is my directory structure:
and the directory where all of this is located is the: /home/user/learning_java
,
Now I have already seen this question: using classes in java archieve, but for some reason this didn't solve my problem(so this is not a duplicate).
I am only using the text editor vscode and hence only compile from the terminal(am on ubuntu).
Please ignore the .class files,
The constructor.java
file has the source code:
package com.beez.java;
public class constructor {
private String name;
private int age;
private int weight;
public constructor(String var1, int var2) {
this.name = var1;
this.age = var2;
this.weight();
this.weight = this.get_weight();
}
public void weight() {
double var1 = 5.13D;
this.weight = (int)((double)this.age * var1 + 3.0D);
}
public int get_weight() {
return this.weight;
}
public String get_name() {
return this.name;
}
public int get_age() {
return this.age;
}
}
and the run_test.java
has the source code:
import com.beez.java.construc.constructor;
import static java.lang.System.*;
public class run_test{
public static void main(String[] args){
constructor niraj = new constructor("niraj", 12);
int niraj_weight = niraj.get_weight();
out.println("weight of niraj: "+niraj_weight);
}
}
and I compile in the terminal from the directory: /home/user/learning_java
which is where the run_test.java
resides using:
javac -classpath '.:com.beez.java.construc.jar' run_test.java
and this is the error I get:
run_test.java:1: error: package com.beez.java.construc does not exist
import com.beez.java.construc.constructor;
^
run_test.java:7: error: cannot find symbol
constructor niraj = new constructor("niraj", 12);
^
symbol: class constructor
location: class run_test
run_test.java:7: error: cannot find symbol
constructor niraj = new constructor("niraj", 12);
^
symbol: class constructor
location: class run_test
3 errors
What is the error I'm making?