What is ‘java ’ syntax?īefore we start troubleshooting why the terminal is returning us an error when trying to execute, first we need to look at the syntax of the command. In targeted IDE’s, this isn’t the problem as the IDE keeps a pointer pointing towards the current working directory. Since you are executing the command from the command line terminal, the computer does not know where the class is to be found or where it is located. In some cases, you have to add the correct file path and point the Java terminal to the correct location. The java command was not able to locate the class at the correct directory. The message ‘Could not find or load main class’ means that the first step of the Java engine fetching the class for execution has failed. What causes the error ‘Could not find or load main class’ in Java? Before moving forward, we assume that you have a basic knowledge of Java programming language and how it works. Like mentioned before, this error is mostly not related to the system and the user makes a mistake in several scenarios as shown below. Could not find or load main class- Java command line The reason why this happens is mostly due to the user’s programming mistake while declaring the class. The error ‘ Could not find or load main class’ occurs when using a java command in the command prompt to launch a Java program by specifying the class name in the terminal.
0 Comments
Leave a Reply. |