0

I cannot resolve the current issue I am experiencing with Java. I am familiar with PHP/MySql, but not with Java.

Here is my Java code:

package day1.examples;

public class MyFirstClass
{
    public static void main(String[] args)
    {
        System.out.println('Hello World');
    }
}

Problem: When I go to run the program as Java, I receive the following warning:

enter image description here

Then, I am receiving the following error in my console: Error: Could not find or load main class day1.examples.MyFirstClass enter image description here

Question: Why is the above code (which I assume is appropriate) not working? Furthermore: Why am I receiving errors?

Please note: This is my first day using Java

EDIT (problems):enter image description here

7
  • 3
    Try clicking on the "Problems" tab to see the... problems Commented Sep 10, 2015 at 17:32
  • Because something is wrong in the configurations. Right click the project , select properties and see java build path. Looks like you don't have the current folder . in the classpath. Commented Sep 10, 2015 at 17:33
  • 1
    Double qoute your Hello world. Singel is for char and nog string. Commented Sep 10, 2015 at 17:34
  • Did you set correctly your JAVA_HOME environment variable? Probably that's giving you the error. Or might have something to do not 100% sure Commented Sep 10, 2015 at 17:36
  • I have added a photo of the 'problems' tab. Commented Sep 10, 2015 at 17:38

4 Answers 4

4

Remove the currently bound JRE from the project & add a new system library using a JRE that exists on your local system.

Sign up to request clarification or add additional context in comments.

2 Comments

This has resolved my issue! Everything is working fine now! Best regards!
I have added "JRE system library[jdk1.8.0_60]"
1

The reason it will not work is because the compilation is failing. The reason it is failing it because you used single quotes (') to enclose "Hello World". You should use double quotes (") as you are trying to indicate a String, single quotes are used for individual characters.

1 Comment

Unfortunately, I have changed the quotes to doubles, yet the same problem exists.
0

You should tell eclipse which Main calss you want to run. Go to Run --> Run Configurations.. and select the main class to run.

Comments

0

System.out.println('Hello World'); is not valid Java. Try System.out.println("Hello World");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.