Unable to run Java program in Eclipse Juno 4.2 - java

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:
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)
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
From Eclipse, File > New > Java Project
List item Uncheck Use default location and navigate to <PROJECTS_DIR>/components-FrameDemoProject
Hit Finish
Drill down to src/components/FrameDemo.java
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.

Related

Unable to config and run a Java project in IntelliJ

Me and a few other students are building a game with Java at university. Someone else setup the basic structure for the project and i pulled the repo and tried to run it.
When i run it i get
this window
When i open the config, i am unable to add the main class, it is located in the file shown in the image. The OK button is disabled. You can see that here.
I'm running the latest version of IntelliJ, JDK 9 and Windows 10. The project in question is built with LibGDX. The full repo and folder structure can be seen here.
I am able to setup my own project and run my own apps, i just can't run this specific project.
Please help.
I think, since you have no "Java" directory, Intellij does not recognize any folder as Java Sources. You'll have to do that manually by rightclicking and mark the desired directory as Source root.
I figured out what the problem was, and of course - it was obvious. The project was setup with an old version of Gradle (2.4) and i was running Java 9. I installed Java 8 and made the project run.
The OK button was disabled because the project hadn't built properly (i though it had) so it couldn't find the class i needed to run it.

Eclipse plugin not working properly

I developed an Eclipse plugin that compiles and runs java code in German. The technique I am using is that I translate the code to English and pass it to Java Compiler and get the results back and print it in the console.
The problem is that the plugin works when I run the plugin from Inside Eclipse but when I install the plugin in Eclipse so that when I open Eclipse it already exists there and start to test if a real user uses my plugin and creates a new Java project and try to the compile button in my plugin it says [The chosen operation is not currently available] ![Here is the the way I run and it opens a new Eclipse application with the installed plugin ]
Any help please
the way you installed your plugin sounds a little weird to me. So at first please try to export your plugin via the Export Wizard.
(Select Export -> Deployable plugins and features from your projects context menu)
Export your project as jar file and copy it to the 'plugin' folder of your eclipse instance.
After that it might be helpful to debug your plugin on OSGI-Level as there might be a problem loading your plugin (at least the error description you have posted indicates that).
Run eclipse with -console -noExit -consoleLog flags to open an OSGI console for debugging. After that try running ss <your-plugin-name> to see what the state of your plugin is.
The output gives you the ID of your plugin and the state it currently has. If the state of your plugin is not ACTIVE try running start <your-plugin-id> to see whether it starts correctly. If there is a problem starting your plugin you should get a respective log message. Feel free to post it here in case you need further help.
Otherwise there are plenty of options what might cause your problems, so maybe its better to try the steps I have described above before getting into details.
If you want to run eclipse plug-in withput using Eclipse Application , then you need to make a Feature project.
Now if your algorithm has something to do with system Path , you must
check Unpack plug-in and you should read the resource accordingly.
Like PLatformUI.getWorkBC() etc..
No other eclipse plug-in (jar) should be inside plugins directory of eclipse of same name of your plug-in. Ensure for this.

Issues with Eclipse while working on and Android project

I am currently developing an application with my software engineering classmates. I am experiencing a few issues with Eclipse, however. But first, some information about my Eclipse: I am running version: Juno Service Release 2 with a build id of 20130225-0426. I am running Eclipse on my MacBook with OS X Mountain Lion 10.7.5. I am using SVN to upload and download the project to a repository through assembla.com.
First, Eclipse will not recognize any errors. If I purposely type random characters, Eclipse does not underline them with red.
Next, whenever I type "this.whatever" or "# for javadoc" I receive the following message: "this compilation unit is not on the build path of a Java project." I can click "OK" and continue with no problem though.
Finally, whenever I attempt to run the program I receive this message:"The selection cannot be launched, and there are no recent launches."
Other notes: I do not have any of these issues with any of my other projects in my workspace. I also have another project using the assembla repository that does not contain these issues. These issues just occurred all of the sudden.
Edit: None of the other members in my group are experiencing these issues. I have attempted to download the project from the repository on a different machine and I still have these problems. I have attempted to delete the project from my workspace and re-download. Still a no go.
Update: I even installed the Android Development Kit and used the included copy of Eclipse. It will still not work properly.
What is going on with my Eclipse?
Since I guess you're in start phase of android coding and you're not addicted to a special IDE, I strongly recommend the IntelliJ IDEA instead of Eclipse for Android development. I have tried Eclipse already and because of its weaknesses, now I'm using IntelliJ. Eclipse is not the best IDE for Android development and have a long way to become the one.
IntelliJ IDEA
I suggest you try installing the ADT bundle in a new location and see if you still have these problems. The ADT bundle includes the latest Android SDK along with a version of Eclipse with the ADT (the Android Developer Tools plugin) already installed and configured. It's possible that you have (or have had in the past) other Eclipse plugins that affect how the Java tools in Eclipse work, possibly in a way that interferes with ADT. I have personally had problems like this in the past with tools like Aptana, where even after uninstalling there would be problems.
Eclipse is telling you already with the above error message: You don't have your sources on a build path, but just in some folder.
Either you have created a simple project instead of a Java project, which then also doesn't do anything Java specific. Or you have created your Java files in plain folders, instead of source folders.
The best way to sort this out is to create a new Java project using the Eclipse "New..." wizard from the main menu. Compare the result of that to your project. The two important things are: The project has an icon with a small "J" overlayed. The Java sources are shown in packages, which themself are in source folders (with a package overlay), not in simple folders.

Eclipse does not work with JSP

I'm following this tutorial about using Google engine API to create web application.
When I add any file with .jsp suffix into my war folder the project will not compile any more.
What can be the reason ? If you need more information please just leave some comment. Thank you.
Can it be that I it cannot compile because I did not download "Eclipse for Java EE developers" but only "Eclipse for Java developers" ?
I'm not sure. I see <Java EE> in the title bar in your Eclipse screenshot which is typical for Eclipse for Java EE developers. So you have likely the right version. If you are able to do File > New > Dynamic Web Project then you definitely have the Java EE version or at least the one with WTP. More detail can be found in Help > About Eclipse.
the error in Markers tab is "Your project must be configured to use a JDK in order to use JSPs"
You need to install the JDK. Go to the Java SE download home page and click the leftmost one of the four big buttons. Done that, go in Eclipse to Windows > Preferences > Java > Installed JREs, select the existing JRE, click Edit and let the JRE home path point to the JDK folder.
It it asking you if you want to run even though it found errors in the project. First, what are the errors and can you fix them easily? Eclipse gives pretty good error messages. If the errors are from validation, turn them off in the project settings, then try running the project again.
Otherwise, double check that you are using the exact code from the tutorial. Copy the code from Google and save it into a separate file. Then select your file, and the new file, right-click on the two files and use Eclipe's file-compare to show you if you missed anything.
[edit]
You could install the EE version to a different directory. Different versions of Eclipse do play nice with each other, they're just huge. Do not import your project into the EE workspace. It will come across as a plain Java project and you need a Web project. Create a new Web/JSP project and then copy the files over.

Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files

I'm a Java noob (but have been programming for 25+ years, and have worked with OO languages from day 1).
All of a sudden I started getting this error:
Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files.
Not sure what caused this condition, and not sure what Java's asking me to do. I'm working in the NetBeans IDE. The last thing I attempted to do is add some binary (image) resources to my project.
In my case the JDK setup in Netbeans was fine. It was just one of those strange Netbeans issues that come out of nowhere.
My fix was:
Clear the Netbeans Cache i.e. delete the folder:
C:\Users\\AppData\Local\NetBeans\Cache\
It means you haven't told netbeans where your Java 1.6 installation is. Go into settings, add the JDK (JDK->Add->New), and select the directory above 'bin' for your JDK16.
This error can occur at two scenarios:
Right click your netbean project -> Properties -> Libraries
After select Libraries , right panel on top you can see "Java Platform" combo box. This Jave Platform is missing for your project. You need to add using Manage Platforms bottom beside Jave Platform combo box.
Even thought scenario (1) is correct it can happen. Because your project has reference to another netbean project in your Libraries. This reference project is missing Jave Platform.
I have Linux in my office and Mac in Home and this problem is frequently when I share projects in github, I solve it removing the build directory and doing clean and build.
Right click on project - Properties - Libraries - Select the correct jdk version from the Java Platform combobox.
NetBeans bug
If your project depends on other projects, open and clean build all of them(that fixed it for me).
Most likely cache-related stuff. Clean up NB cache as suggested by someone before
You should remove the files under private folder in the nbproperties folders.
for me any recommended way early didn't helped, but changing in project Properties -> Source/Binary format to JDK 7, Save than change back to JDK 8 fixed this error

Categories