After you run the javac
command normally and create the .class
file,
I try to execute the command java
plus it gives this problem of not being able to locate nor load the main class.
I think it might be a mess on the environment variables because I'm starting now to learn programming and really do not understand much about such variables.
Anyway, I used this "step-by-step" in the link below to configure system variables:
I used only the commands javac
and java
in cmd
, apart from being located in the directories.
Using this code below, just after the java command to run the program, it occurs. Error: The main CPrincipal class could not be located or loaded.
import javax.swing.JFrame;
public class CPrincipal {
public static void main (String args[]){
JFrame janela = new JFrame ();
janela.setSize(500,300);
janela.setVisible(true);
}
}