简体   繁体   中英

Eclipse Can't find default Java Classes on Mac OS X

I have done Android and C development in my copy of Eclipse, but have never actually done Java strictly. When I add code that compiles using "javac codename.java" to an eclipse project, eclipse gives me errors and can't recognize statements like import java.io.* . I believe this is due to a problem with my class path and I have tried adding some paths like library/system/java but have not had any success. Any ideas for a solution?

If Eclipse is having troubles with classes delivered by JDK, I would suggest checking out if it (thus - JDK) is properly installed. You may do that by going to menu Window > Preferences and started typing "jdk" in search input. It should point You to Java > Installed JREs . Check if there is proper JDK installed (if not - You may add it there). After that try to clean Your project - menu Project > Clean... .

Hope this helps, regards.

如果进入首选项对话框并转到Java / Installed JRE,请确保这些路径正确。

In order for Eclipse to recognize source files as Java and compile them, your project has to be a Java project. Putting a .java file in a project that wasn't created via New / Java Project won't work.

Please try creating a Java project and put your .java file in it.

On os x the default location (right now anyway) is /System/Library/Java/JavaVirtualMachines/[VERSION].jdk/Contents/Home
The default location is available from /usr/libexec/java_home .
That said, I've never had any problems with eclipse not finding the jdk, usually it's all automatic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM