I created a new project and working with eclipse (used eclipsify command).
basically, I moved the app directory from an old project to the new one I created.
the problem is that eclipse doesn't recognize the views. I get errors like:
views.html.viewTopic cannot be resolved to a type
I tried to play compile but it didn't help.
so I got 40 errors. all of them connected to the fact that the views aren't compiled and therefore, the eclipse doesn't recognize them (my guess of course).
what can I do?
by the way, the old project compiled and ran without a problem (I used intellij)
For Java Play Framework v2.4.6 (activator v1.3.7) with Eclipse Mars:
So that you will not have a "can not resolve error" with your viewTopic.render(), you can add this <classpathentry kind="lib" path="target/scala-2.11/classes"/> to your .classpath or right-click on your project -> Build Path -> Configure Build Path -> Add Class Folder and make it point to target/scala-2.11/classes.
Run 'play eclipse' on the command line
In Eclipse, refresh your Project via hitting F5
Re-run the command in play console with the sources this time:
$ eclipse with-source=true
And then go to eclipse and clean your project and build all
According to jetbrains, the issue with templates is fixed. If you have play 2 generated source sources included in the IDEA project then you should exclude this folder from the project
http://www.jetbrains.com/idea/webhelp/configuring-folders-within-a-content-root.html
and do File | Invalidate caches and restart.
If you have an SBT project, open it in IDEA via File | Import Project | Sbt type project
Make sure to use the latest Scala and Play 2 plugins.
Close eclipse project
activator eclipse
activator compile
Open eclipse project
Add target/scala-[your-version-here]/classes to your build path as a class folder
The best you can do is just search the Stack Overflow as this topic was discussed really many times.
Playframework - Eclipse can't detect a new template
How to make Eclipse see the changes in Play! compiled templates?
scala code causes error in eclipse for playframework-2.0
etc, etc...
OK, I solved it.
I created a new app again
moved app dir
only then ran the command play idea
Related
I just installed Eclipse Oxygen and tried to open an existing project into the workbench but I get this error:
The project was not built since its build path is incomplete. Cannot
find the class file for java.lang.Object. Fix the build path then try
building this project
I tried right clicking on the project - went to Properties - Java Build Path - Libraries - Add Library - JRE System Library and selected Workbench default JRE (jre1.8.0_60).
I then cleaned and rebuilt the project but it then causes more errors to come up like:
ActionBar cannot be resolved to a type
Activity cannot be resolved to a variable
AdapterView cannot be resolved to a type
ArrayAdapter cannot be resolved to a type
Here is what made the error disappear for me:
Close eclipse, open up a terminal window and run:
$ mvn clean eclipse:clean eclipse:eclipse
Are you using Maven? If so,
Right-click on the project, Build Path and go to Configure Build Path
Click the libraries tab. If Maven dependencies are not in the list, you need to add it.
Close the dialog.
To add it:
Right-click on the project, Maven → Disable Maven Nature
Right-click on the project, Configure → Convert to Maven Project.
And then clean
Edit 1:
If that doesn't resolve the issue try right-clicking on your project and select properties. Select Java Build Path → Library tab. Look for a JVM. If it's not there, click to add Library and add the default JVM. If VM is there, click edit and select the default JVM. Hopefully, that works.
Edit 2:
You can also try going into the folder where you have all your projects and delete the .metadata for eclipse (be aware that you'll have to re-import all the projects afterwards! Also all the environment settings you've set would also have to be redone). After it was deleted just import the project again, and hopefully, it works.
In Eclipse, Right click Project -> Maven -> Update Project. It fixed errors in my project.
I'm also using Eclipse Oxygen, migrated from Mars. I faced the same error. I deleted .metadata, .recommenders folders and added projects from archive and issue is solved. I also use Android Studio but i like Eclipse much more.
At my system the Java Runtime JAR file jrt-fs.jar was not found because it was in the wrong directory. This file should be located in the "lib" subfolder. If you installed Java at "C:\Temp\java" the file should be here at C:\Temp\java\lib\jrt-fs.jar .
These are the steps to make jrt-fs.jar available to Eclipse:
Window / Preferences -> the "Preferences" Window opens
Select in the left menu: Java / Installed JREs
Press the [Add...] Button -> A window opens
Select "Standard VM" - The window "JRE Definition" opens.
Enter your path information:
JRE home = "C:\Temp\java"
JRE name = "MyJRE"
Select [Add External JARs...] to link the jrt-fs.jar
JRE system libaries: "C:\Temp\java\lib\jrt-fs.jar"
It worked for me with OpenJDK12 and Eclipse 2019-09 (4.13.0).
Eclipse reported me this error:
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project
I had faced this problem. I added the C:\Users\Office 2\android-sdks\platforms\android-19\android.jar to the Java Build Path's Library. And the project started to run again.
The problem occurred due to my carelessness. Yesterday night I was updating the Android SDK, and at the same time I tried to run the project, while the SDK Manager was uncompressing the system image. The Project couldn't start and the error occurred.
I tried all the methods given by others. But nothing worked. It solved when I added the android.jar to the library.
I guessed it that android library is missing. not the Java, when I saw the errors only at the android methods and imports. But when I read the posts, I got confused and wasted some time trying wrong way.
I had faced the same issue and tried different solutions, I have reinstalled my JDK 11 and restarted the machine, after that the issue gets resolved.
I got this out of the blue in a workspace that was working properly before. This problem seems to indicate that the project configuration somehow got corrupted.
Restarting Eclipse didn't help, but in the same vein as the answers dealing with Maven, regenerating the Eclipse project config with:
./gradle eclipse
or
./gradlew eclipse
if you use the wrapper, solved this problem for me.
I have similar issue when importing Spring Boot, jdk 11 (using
inside docker) project to Eclipse 2019 (2021), in Ubuntu, instead when
importing to Inteelij IDEA Community or NetBeans IDEs they do
not produce the same set of after-import errors as in Eclipse.
The Spring Boot is multimodule maven projects and two child
modules give such 2 "problems" in appropriate problems tab:
The project was not built since its build path is incomplete.
Cannot find the class file for java.lang.Object. Fix the build
path then try building this project
Next 2 errors are produced in two classes of aforementioned
maven modules:
The type java.lang.Object cannot be resolved. It is
indirectly referenced from required .class files
Manipulation with adding JDK 11 to submodules buildpath
just leads to the thousands of problems. Also it is
got when I use Eclipse-File-Maven-Update.
Moreover when I try to edit most of existing classes or add new ones
I got red underline that tells
Implicit super constructor Object() is undefined for default
constructor. Must define an explicit constructor
. So almost no opportunity to use Eclipse
even at prebuild stage as docker-compose should run build and
run. Indeed I noted that such issue is produced just when project
also uses modules (module-info files introduced in java9).
When I import project on jdk 8 (even not installed on
system), or even on jdk11 without module-info files all
is fine in Eclipse after import.
Another difference is that of when I use problem old no module
project the Build Path is composed with jre environment 8 and
maven dependency items, but when using
"module-info" project the Build path contains -module path,
and -classpath. So I even do not know where to add jre 11,
indeed adding does not resolve issue, just make more errors.
So what is the resolution of the case??? What settings to do
in Eclipse?
I have a main method in a package in one of my projects. Say, the package is com.ant.car. I am trying to run and/or debug this main method, and I keep getting the error Could not find or load main class com.ant.car.
I've searched this problem, and it seems like I can't figure out what is wrong.
1) I've checked run configurations. In Run->Run Configurations, I've checked that the Main class is com.ant.car.
2) I've checked build path. If I right click on the project, I select Build->Build Path, and under the Libraries tab I make sure there are no missing folders with red Xs next to them.
Not really sure what else to do. Any suggestions?
Project -> Clean
this is working
Try updating project by right clicking on it. Maven -> Update Project
Today I ran into the same problem and I tried a lot of answers. Nothing helped. Cleaning the project, build automatically is already checked, deleting .metadata, etc.
Eventually I tried this and it worked perfectly:
menu Project -> Properties
Java Build Path, tab Libraries
Remove the JRE System Library from there, press Add Library, take the JRE System Library and press Next. Workspace default JRE and press Finish.
What worked for me:
Menu Project -> Properties
In Java Build Path, tab Libraries
Delete all libraries with a red [x] next to them.
In my case, problem happened when I switched from Kepler to STS IDE.
The solution to this was the following:
Close Eclipse/STS
Use a file explorer on your operating system to navigate to your workspace (In my case, I'm on Windows so I used Windows Explorer)
Delete the .metadata directory (or to be safe, copy the directory somewhere else to be safe, then delete it)
Restart Eclipse/STS
Is there a more improved answer than this? I don't want to look like I'm trying to boost my own reputation points, so if someone can provide a better answer then please do so.
Sometimes the problem can be caused by some newly added dependencies. Try removing the recently added jars. That's how I fixed my problem.
Project -> Clean... -> check project not working -> Clean
I already had build automatically set, but forcing STS to rebuild it fixed it.
This issue occurs when the main .class file moved or not found because you changed the directory for committed/shared the project into the git or another repository.
To Resolve this issue -->
Remove existing run configuration and new one.
Find the parent pom.xml or project pom.xml and open cmd/command prompt and run the below commands,
mvn clean install package
mvn eclipse eclipse
It worked for me:
1. Delete metadata from work-space directory.
2. Import the project again, but selected copy to work-space option.
I think the cause for the error was Non-English characters in the original saved directory.
You just need to delete Run Configuration file and restart STS and run command -mvn clean install and try to restart the service
The Error "Could not find or load main class com.ant.car" occur when your class is not in build path. please make sure that .class file is generated and it's in build path ..
I faced the same issue..
just do follow these steps:
STS/Eclipse --> Project --> Enable "Build Automatically"
then refresh your project, it will resolve your issue.
Still not refreshed your projects automatically, just restart your STS and check.
Hope it will help you.
I think .class files are deleted/missing from JavaProject/bin folder.
To resolve this issue ->
1) Just cut paste and save the code contents of all the files that you are using then .class files will be regenerated.
2) Then run the code and you can see it works fine if there is no syntactical errors.
1 ) Clean the Project
2 ) Enable build automatically Option
3 ) Update the maven project by use the short cut Alt + F5
Deleting target folder manually and mvn clean install worked for me
A quick and easy fix is to directly run your SpringBootApplication class (i.e. Right click, Run As -> Spring Boot App). This runs the app and creates a run configuration automatically.
I spent several hours on this issue, finally it is fixed by doing this:
Properties -> Java Compiler: uncheck the checkbox "use '--release' option"
This worked for me to solve the error. (I got this error after removing AWS ToolKit)
Close the Eclipse/ STS Eclipse.
Go to the WorkSpace folder.
Delete the .metadata folder.
Open the eclipse.
Run maven install on pom.
Run the project with your Run configuration.
Remove project from STS/Eclipse
Close or Refresh the Eclipse/ STS Eclipse.
Run maven install on pom.
Run the project with your Run configuration.
Tried above mentioned steps to resolved issue.
You can try one of the two solutions below:
Solution 1: Right click the project -> Gradle -> Refresh Gradle Project.
Solution 2: Add gradle or maven in your environment variable. My problem was that I had not added gradle in my environment variable. Before, make sure Gradle or maven is installed in your OS.
I tried all the answers but finally what worked for me was deleting the project from eclipse workspace and importing it again.
How do I get .jsp/.xhtml/.html files to trigger a compile/package goal in a Google App Engine + Maven + Eclipse setup? (actually it's the same for IntelliJ & Netbeans)
The .java files cause a compile goal just fine, which causes the target directory to update, which is then picked up by appengine:devserver, but nothing else works.
I've seen lots of people asking this, but no solution.
I'm using the simple GuestBook Maven archetype:
mvn archetype:generate -Dappengine-version=1.9.15
-Dapplication-id=your-app-id -Dfilter=com.google.appengine.archetypes:guestbook-archetype
Followed by:
mvn appengine:devserver
Eclipse Juno is setup to "build automatically", so touching a java file triggers the goal, just nothing else.
Frustrated!
UPDATE: I'm using the GPE for Juno EE.
-- shane
If you install the GPE, you can run from within the eclipse IDE. When running in debug mode, jsp and java file changes will get hot-loaded. You can also use the JRebel plugin for eclipse to save time on redeploys/restarts.
EDIT:
If you're still having trouble, ensure that you have the m2e-wtp plugin installed into your eclipse, it enables a bunch of secret sauce. m2e is now intrinsic, i'm not sure about m2e-wtp. If I look in 'About' for eclipse, I can see a button for wtp. m2e-wtp
For the record, this is actually unnecessarily hard. But once it works, it works.
I feel there should be a better way, but this is a workaround:
Project -> Properties -> Builders
Click "New…" to create a builder that will invoke the mvn binary.
Here's my settings for it.
Location: /usr/local/bin/mvn
Working directory: ${workspace_loc:/} (use browse workspace to populate this)
Arguments: -Dmaven.test.skip=true prepare-package war:exploded (these arguments seem to be the fastest way to produce the exploded war, ~1 second in my case)
In Build Options, deselect "Allocate Console" and select "Launch in background".
Except the 1 second delay, this works flawlessly for me.
I can generate Eclipse files for a Play 2.1 project via:
$ play eclipse with-source=true
... and then I can do File -> Import [Existing Project] in Eclipse.
That works great -- but when I want to add a dependency to project/Build.scala, I can't figure out how to get this to update in Eclipse. The only working solution I have is:
Delete project from Eclipse
Re-run play eclipse
Re-import project into Eclipse
Which can't be "the right way." (Or can it?)
Related question (but addresses an older version of Play):
Eclipse not updating referenced libraries for my Play framework application
This works for me (using Eclipse Juno):
If you add a dependency, use the play console to reload the project:
[play] $ reload
Then rebuild the eclipse configuration:
[play] $ eclipse
Then refresh the project within eclipse by right clicking on the project and clicking Refresh.
There's no need to delete the project and create a new one.
I'm doing this for a project in AP Computer Science.
Basics:
Mac OS X 10.5.8
NetBeans 7.0
Android SDK 3.0 (Level 11)
So I'm trying out some of the Android API Demos in NetBeans (I prefer it over Eclipse) and I'm using samples\android-11\ApiDemos\ for the source. The R.java file is not generating and "package R does not exist". I've looked at other answers, and they say to Clean and Build the Project, but that option is grayed out in NetBeans (so are just the "Clean" and "Build" options). Any ideas on what I should try before I switch to Eclipse? I also have a computer running Windows 7 if I need to change the OS. Thanks!
Right-click your project and hit build. It will generate the missing R class for you. At least it did for me in Netbeans 7.1
Just right-click on the project, select the "Update broken project" command, then "Build" is not gray no longer. Build it, OK!!
The right-click menu command
I had the same problem, but all I did was a "Clean and Build", and then the R file was created by Netbeans (running 7.1).
I had to run netbeans as administrator on my Windows 7 pc before it could build the R file. If you're saving the project to somewhere "secured", make sure that Netbeans gets all the neccessary rights to read/write/edit that location
Get Android plugin for NetBeans and then you will be able to open these project and play with them. The project home page is http://www.nbandroid.org/
Some initial steps may be needed. Set up SDK location in Tools | Options | Misc | Android. Then check that your project has some build target set in (select project, r-click and go to project properties). Once the build target is set plugin will (re-)generate build script and required .properties files. You'll be able to run build then.
-Radim
Several things could be going on, but what happens to most people is:
an error makes R not build
R is unknown, they try to fix the error by importing packages
There is now a "import R.id" or something in the java files
...
Loss
Also, it could just be point one, that a problem with the setup (manifest broken, wrong project props, or something like that) make R not generate, and then you won't have R.
But really, I've seen some examples of people doing point 3.
I had the same problem and it was due to the package of R not being the same as the one for Main. I just moved Main to the same package as R and everything is fine after I hit Build.
In my case adb was missing.After installing adb everything worked fine.
You can just right-click the project and choose build from the context menu.
(This works for me. I am using NetBeans 8.1)