Creating variable in one class, using other class to set its properties

Basically I have 2 classes. The main class has the main definition of all the variables, Box, Material, etc. Then I have another class called class2, it is supposed to initialize values and properties for each of the variables from the main class. The problem is, the class2 says java.lang.NullPointer Exception with


heres some code:

public class Main {

Material mat;

public static void main(String[] args) {

public void simpleInitApp() {





public class2 extends Main {

public void Initialize(){

mat = new Material (“Common/MatDefs/Misc/Unshaded.j3md”);




Please help me on this, because I need to split a lot of code into seperate classes.

You should learn more about what classes are and how they are used before you “split your code into classes”. Try to get a better grasp on what “object oriented programming” means and read a bit more in the wiki when you understand these concepts. Otherwise it makes more sense to keep it all in one file :stuck_out_tongue: