How do I use JDK 7 on Mac OSX?

Posted by Yko on Stack Overflow See other posts from Stack Overflow or by Yko
Published on 2011-06-07T15:12:21Z Indexed on 2012/11/10 11:02 UTC
Read the original article Hit count: 166

Filed under:
|
|
|

OK. This is a newbie question but I can't figure it out...

I would like to use the WatchService API as mentioned in this link: http://download.oracle.com/javase/tutorial/essential/io/notification.html

After reading around, I found out that WatchService is part of the NIO class which is scheduled for JDK 7. So, it is in beta form. It's fine.

http://jdk7.java.net/download.html has the JDK which I downloaded and extracted. I got a bunch of folders. I don't know what to do with them.

Then, I read around some more and found that some nice group of people created JDK 7 as a binary so someone like me can install it easily. It is called Open JDK: http://code.google.com/p/openjdk-osx-build/

So, I downloaded the .dmg file and instal it. Then I open "Java Preference" and see that OpenJDK7 is available.

So, now I feel that I can start trying out WatchService API. From the tutorial in the first link, the author gave a .java file to test it out first and make sure that it is running. Here is the link to the file: http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java

So, I boot up Eclipse (actually I use STS) and create a new Java project and choose JaveSE-1.7 in the "use an execution environment JRE:". Under the src folder, I copy pasted the WatchDir.java file.

And I still see tons of squiggly red lines. All the "import.java.nio.*" are all red and I cannot run it as a Java app.

If you read this far, thanks a lot. So, now...

What do I need to do?

Thanks.

EDIT: I actually did not pursue using Java 7 but there are a lot of interest in it and it seems like people keep answering this question. What should I do to make it more relevant to people who search for it? Let me know by PMing me. Thanks.

© Stack Overflow or respective owner

Related posts about java

Related posts about osx