简体   繁体   中英

Unable to run Java program in Eclipse Juno 4.2

I reinstall my Eclipse environment every year when the new version is released. The most recent release - Juno - however, does not work as expected.

Currently, when I try running demos from Oracle, for example, it asks me to select an Ant file to run before compiling. After creating a blank Ant file to bypass the requirement (which I thought was rather dumb, since I don't think TDD is something that should be forced on people), it still refused to run, saying the "Selection could not be launched."

I understand that Juno is an update from the 3.x track to the 4.x track, but this seems a little ridiculous to me. What can or should I do so I can get Eclipse back up and running again?

Just to clarify:

  • All files in question are on my Eclipse workspace path
  • I don't do much in the way of Java development, though I know I'll need to do so soon. Hence, my unfamiliarity with the most recent version of Eclipse.
  • I would like to run my files & projects without Ant files. I know it has something to do with Run configs, but I don't know how to change them.

Here's what I did to run the demo from Eclipse Juno:

  1. Downloaded the project from http://docs.oracle.com/javase/tutorial/uiswing/examples/zipfiles/components-FrameDemoProject.zip (if this is not the correct demo, then please provide the link you're using)
  2. Unzipped it to my projects directory (not my workspace), so that you have:

    PROJECTS_DIR/components-FrameDemoProject/src

    PROJECTS_DIR/components-FrameDemoProject/nbproject

    PROJECTS_DIR/components-FrameDemoProject/build.xml

  3. From Eclipse, File > New > Java Project

  4. List item Uncheck Use default location and navigate to <PROJECTS_DIR>/components-FrameDemoProject
  5. Hit Finish
  6. Drill down to src/components/FrameDemo.java
  7. Right-click on FrameDemo.java and select Run As > Java Application

Let me know if any of these steps give you trouble.

Take a look at you project properties and select the Builders entry. Do you see an Ant Builder entry? Try to select or create a Java Builder entry instead.

I just created a new Java Project in Juno and added the FrameDemo.java source. In my case, the Java Builder was selected as the default for this new project.

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