How can i fix this problem

Hi guys I need some help I have just installed the eclipse IDE and am trying to run the Hello World program but it is showing this image

@suubi7 Oh sorry about this! kindly checkout out the tutorial on this link.

1 Like

@suubi7 which steps have you done to create a class in your eclipse?

i went to the file right clicked and then went to new then selected class and eclipse did the rest

Sorry about that , hope one of these helps…

Try running it using the command line (without using Eclipse), here is how to compile and run java programs using cmd or eclipse Do you get the same error?

You can check the Classpath setup in Eclipse too, hope Techwalla helps

you seem to have created the class manually , and you seem to miss the Package declaration.

The easy way is to use Ecclipse to create your class

  1. Start Eclipse.
  2. Create a new Java Project:
  3. File->New->Project .
  4. Select " Java " in the category list.
  5. Select " Java Project " in the project list. Click " Next ".
  6. Enter a project name into the Project name field, for example, " Hello World Project ".
  7. Click " Finish "–It will ask you if you want the Java perspective to open. (You do.)
  8. Create a new Java class:
  9. Click the " Create a Java Class " button in the toolbar. (This is the icon below " Run " and " Window " with a tooltip that says “New Java Class.”)
  10. Enter " class name " into the Name field.
  11. Click the checkbox indicating that you would like Eclipse to create a " public static void main(String[] args) " method.
  12. Click " Finish ".

thank you i have done this but problem still persistent

The error seems to be caused by the default JRE( Java RunTime Environment) that is failing to provide the class libraries and other resources that your Java program needs to run .

Hint: Remove the default JRE present in your workspace and set it to JRE Version corresponding to your installed Java version
Follow these steps and share your experience

  1. Right click on your project
  2. Go to Build Path–> Configure Build Path .
  3. Go to Library. Under Module Path click JRE System Library and remove the current JRE System Library. The Remove Button is on the right side labelled "Remove " .
  4. Then click “Add Library” which is just at the right side
  5. Then Choose “JRE System Library”. Then click Next.
  6. Choose “Execution Environment” instead of “Workspace default JRE”
  7. Then in the drop down menu, choose the JRE version that corresponds to your installed java --version.
  8. Then click finish
  9. Then click “Apply and Close” Button
  10. Run the program again

how do you know the JRE that corresponds to the installed java.

Which OS(operating system) are you running on your pc

1 Like

Windows 10 But i have figured out the problem its now working I have found the JRE thank you for the help

@suubi7 Are you able to run your program

yess Its now running I am even running others and they are giving out put

1 Like

@suubi7 Its a good practice to share what you have done to resolve the challenge so that others who may face a similar scenario in future can be guided prior to the instance. :green_apple:


@kdaud shared the solution on this link

1 Like

@suubi7 Feel free to explore more about JRE architecture with IBM.

okay will definitely do

You must ensure that you add the location of your .class file to your classpath. So, if its in the current folder, add . to your classpath. Note that the Windows classpath separator is a semi-colon, i.e. a ;.

Also, if your source code name is, your compiled code will be HelloWorld.class.

You will get that error if you call it using:

java HelloWorld.class

Instead, use this:

java HelloWorld