no access-control-allow-origin header is present on the requested resource

0 votes
What does "Could not find or load main class" mean? A common error that the new Java developers are experiencing is that their programs fail to run with the error message with a line displayed such as: Could not find or load main class ...

What does this mean, what causes it, and how should a user fix it?
Feb 8 in Java by Rahul
• 8,980 points
48 views

1 answer to this question.

0 votes

The java <class-name> command syntax is one of the ways in which the problem of programs failing to run with the error message can be rectified. At the start, you need to understand the right way to launch a program using a Java command and the normal syntax used is shown below:- 

java [ <options> ] <class-name> [<arg> ...]

In which, the <option> is a command line option which starts with a "-" character, following which <class-name> is a fully qualified Java class name, and <arg> is a given command line argument that gets passed to your application.

The fully qualified name or FQN for the class is written as you would in your Java source code in a conventional manner. For e.g:-
 

packagename.packagename2.packagename3.ClassName

However, some versions of the java command allow you to use slashes instead of periods. For e.g:-
 

packagename/packagename2/packagename3/ClassName

This will initially confuse you and look like a file pathname, but that is not the case here. Please Note that the term fully qualified name is a basic standard in the Java terminology.

Here is a given example of what a java command should look like:
 

java -Xmx100m com.acme.example.ListUsers fred joe bert

The above Java command will browse for the compiled version of the com.acme.example.ListUsers class. After the class is loaded, check and search if there is any method starting with a signature, return type and modifiers which are given by public static void main(String[]). One must also keep in mind that the name of the method’s argument is NOT part of the signature. The method must be passed to the command line arguments ("fred", "joe", "bert") as mentioned in the above line of code as a String[].

answered Feb 8 by Soham
• 8,730 points

Related Questions In Java

0 votes
1 answer

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK

In your Eclipse IDE, go into Window > Preferences > Java > Installed JREs > ...READ MORE

answered Jun 18, 2018 in Java by Parth
• 4,630 points
2,609 views
0 votes
1 answer

What is the maximum Java heap size of a 32-bit JVM on a 64-bit OS?

32-bit JVMs which expect to have a ...READ MORE

answered Nov 15, 2018 in Java by Frankie
• 9,830 points
1,785 views
0 votes
1 answer
0 votes
0 answers

What is the difference between Default and Protected access specifiers?

Can anyone explain in brief as what ...READ MORE

Feb 6, 2019 in Java by Dishantu
713 views
0 votes
1 answer

Should a class file always be inside package for importing it in jsp page?

Hey there! It is not necessary for the ...READ MORE

answered May 24, 2019 in Java by Karan
1,127 views
0 votes
1 answer

How do i check a ip address range whether it falls in Class A,Class B,Class C

class NetworkId{ static String findClass(String str){ int index = ...READ MORE

answered Feb 16 in Cyber Security & Ethical Hacking by Edureka
• 5,960 points
35 views
0 votes
0 answers

Can an outer class access the members of inner class?

If the inner class is defined as ...READ MORE

May 9 in Java by Kichu
• 17,220 points
15 views
0 votes
0 answers

What is "String args[]"? parameter in main method Java

I am a beginner in java and ...READ MORE

May 15 in Java by Kichu
• 17,220 points
9 views
0 votes
2 answers

What is immutable string in java?

To answer your question, the String is ...READ MORE

answered Feb 9 in Java by Soham
• 8,730 points
222 views
0 votes
1 answer

What are the -Xms and -Xmx parameters when starting JVM?

The XMX parameter helps in signifying and ...READ MORE

answered Feb 8 in Java by Soham
• 8,730 points
170 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP