This program take real life objects and its weights and sorts it based on alphebatical order and then number-wise
But the problem is that when I run this app in Eclipse (haven't tried in NetBeans), it runs fine, but when I compile and try to run it in terminal, it doesn't work and comes with error, "could not find main class"
Keep in mind my java file and class file are in the same folder, so the directory is not the problem
public class testMain {
public static void main(String[] args) {
//makes a new multidimensial array
//the first dimension holds the name of the object
//the second dimension holds the weight
//the 4's in this case show the maximum space the array can hold
String[][] objectList = new String[4][4];
objectList[1][0] = "Teapot";
objectList[0][1] = String.valueOf(1);
objectList[2][0] = "Chesterfield";
objectList[2][2] = String.valueOf(120);
objectList[3][0] = "Laptop";
objectList[3][3] = String.valueOf(6);
//printing the array
for (int i = 1; i < 3; i++) {
for (int j = 0; j < 3;) {
System.out.println(objectList[i][j].toString());
}
}
}
}
By request: In the command line I put,
cd /Users/username/Desktop/JavaProjects
javac ojArray.java
(After it compiled)
java ojArray.class
To compile/run a Java program in terminal, you do the following:
cd
"change directory" command to do so).
cd C:\Users\YourLogin\Desktop
cd ~/Users/YourLogin/Desktop
javac NameOfProgram.java
, eg javac testMain.java
java NameOfProgram
, eg java testMain