1

I am new to Java and have some basic problem. Would appreciate your help guys. I try to run a HelloWorld program but having an error:

"Error: Could not find or load main class HelloWorld".

I noticed that Eclipse saves the project in parallel virtual store directory and not the one I mentioned. When I manually move the project to Eclipse_Workspace directory it works just fine. What should I do for Eclipse to save the files correctly?!

If needed: I downloaded JDK 1.8.0_51 for Win 32 and Eclipse IDE for Java developers (Luna Service Release 1 (4.4.1)). Win7 32 Ultimate. I added a Path value in System Variables -

C:\Program Files\Java\jdk1.8.0_51\bin

Default Resource Path in Eclipse is:

C:\Program Files\Java\Eclipse_Workspace

Thanks

SatyaTNV
  • 4,137
  • 3
  • 15
  • 31
VladBio
  • 11
  • 2

2 Answers2

0

VladBio,

Make sure the following environment variables set correctly:

JAVA_HOME = jdk root folder (C:\Program Files\Java\jdk1.8.0_51)

Path = jdk bin folder (C:\Program Files\Java\jdk1.8.0_51\bin)

To test this go into your cmd (Start -> run -> cmd) and type:

java -version

C:>java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

If you see the correct version then the issue is in Eclipse.

In Eclipse you can check your JDK settings in Windows -> Preferences -> Installed JREs. Your correct JDK should be listed there.

On Eclipse you can also have project specific java version. Right click on your project -> properties. On Library tab you should see something like JRE System Library [jdk1.8.0_45]

Check here for a more detailed answer of what could be going wrong.

I Hope this helps.

Community
  • 1
  • 1
lbighetti
  • 1
  • 1
0

Thanks a lot. I suppose I figured this out. It was a problem in eclipse - it couldnt automatically make a changes in java directory because any change there is allowed only with admin approval. I changed the path in eclipse to a folder on my desktop. It solved out the problem. BTW I tried what you said and the output in cmd was identical to yours. Thanks again

VladBio
  • 11
  • 2