I am stuck on a problem because I am not very good in Java. Could you help me.
PLEASE NOTE: It is not a duplicate as the classpaths are specified and I have already gone through the "duplicate question".
Could you please point me in the right direction?
My code compiles fine and all the compiled files, along with original files, are stored on Desktop.
ERROR
Desktop beeeeaasssst$ java com.StudentDemo
Error: Could not find or load main class com.StudentDemo
Caused by: java.lang.ClassNotFoundException: com.StudentDemo
CODE
package com;
public class StudentDemo {
public static void main(String[] args) {
Student one = new Student(1,"Ravi",45);
Student two = new Student(2,"Amit",65);
Student three = new Student(3,"pooka",55);
System.out.println("Student with highest marks is " + compareStudents(one,two,three));
}
public static String compareStudents (Student one, Student two, Student three) {
Student st = one;
if (two.getMarks() > st.getMarks())
st=two;
if (three.getMarks() > st.getMarks())
st=three;
return st.getName();
}
}
class Student {
private int rollNo;
private String name;
private double marks;
public Student (int rollNo, String name, double marks) {
this.rollNo = rollNo;
this.name = name;
this.marks = marks;
}
public double getMarks(){
return marks;
}
public void setMarks(double marks){
this.marks = marks;
}
public int getRollNo() {
return rollNo;
}
public String getName(){
return name;
}
}
The code compiles and generates 2 different class files but I cannot run the program. I tried 2 ways from my terminal:
java com.StudentDemo . (Since package used is com).
Could you please point me in the right direction?