Imported Eclipse projects not compiling - java

I installed Eclipse 4.2 in new windows 8, and copied and imported all my projects. All projects are based on phonegap so have the phonegap build
None will compile and all have red X by the src> app.java although they work fine in the original eclipse.
I dont understand the errors so dont know where to start:
My Code: The error for the line in () not part of code
package com.x.x;
import android.os.Bundle; (ERROR=The import android.os.Bundle cannot be resolved)
import com.phonegap.*;
public class App extends DroidGap { (ERROR= The hierarchy of the type App is inconsistent)
/** Called when the activity is first created. */
#Override (ERROR = Override cannot be resolved to a type)
public void onCreate(Bundle savedInstanceState) { (ERROR=Bundle cannot be resolved to a type)
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html"); (ERROR = The method loadUrl(String) from the type DroidGap refers to the missing type String)
}
}
Error line 1:
Multiple markers at this line
- The type android.os.Bundle cannot be resolved. It is indirectly referenced from
required .class files
- The type android.content.Intent cannot be resolved. It is indirectly referenced from
required .class files
- The type java.lang.String cannot be resolved. It is indirectly referenced from
required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from
required .class files

Step one is to resolve your JRE setup, which is obviously not in order (java.lang.Object cannot be resolved). Open project properties, Java Build Path, Libraries, and in the list find the item referring to the JRE. Edit this entry. You will probably need to locate the JRE on your filesystem.

I resolved by following this steps..
open project properties, java build path, libraries, search for JRE, select that and remove JRE, click on add libraries, select JRE system libraries, click next and check both execution environment and alternative jre than click on finish. Now again open project than select clean. This will clean your project.

Just go to the compile setting and check project specific setting and then change the compiler version. This can be resolved from there.

I had the same errors on my project, but I fixed it in a different way, here's what I did:
Right clicked my android project (the root) and selected Properties
Clicked on 'Android' on the list towards the left
Ticked an Android Build from the Build Target list, like Android #.#.# (Android 4.0.3 for example)
Clicked okay and that was it! Cleared all my errors :)

Try this:
Right click on package > Build Path > Configure Build Path
Select Java Build Path > click on Classpath, remove the existing JRE libraries.
Add Library > JRE system library > Alternate JRE > Installed JRE > Add > Standard VM > Browse the jre folder and point JRE Home to that directory where you installed JRE > Finish.
This should fix the problem.

Related

Intelij - > cannot access java.lang.Object class file for java.lang.Object not found

I'm trying to set up a new project in Intelij. It's a multimodule project, with a maven parent module, and the application server is WebSpere 9.0.5.0. The problem I encounter is when I ty to run it, I get the error java: cannot access java.lang.Object class file for java.lang.Object not found and then java: cannot find symbol symbol: class String for every single String in the code. If I click on a String to see the problem and see the fix of Intelij, it add the import org.apache.xpath.operations.String;
I'd the same problem, but with Android Studio, similar anyway, try this:
In toolbar: File -> Invalidate Caches / Restart... -> Invalidate and restart
I had the same problem, and in my case, invalidate caches didn't work. A colleague of mine pointed out: make sure in the definition of your SDK, the vm.jar file is included (File > Project Structure > Platform Settings > SDKs).
I added this file to the classpath and the red signs disappeared:
$PATH_TO_SDK/jre/bin/default/jclSC180/vm.jar
If this path does not exist for your SDK, find it!
find $PATH_TO_SDK -name vm.jar

Can't import any referenced libraries from build path in eclipse

I'm trying to work my way through ThinMatrix's Open Gl Java tutorial. And... I'm stuck on video 1. I also worked through the short precursor video where he installed on the dependencies (Including lwjgl 2) in eclipse. Right now I just have the very start of the first class:
package renderEngine;
import org.lwjgl.opengl.Display; //Error is here
import org.lwjgl.opengl.DisplayMode; //And here
//Handle the window
public class DisplayManager {
//Create a display
public static void createDisplay() {
Display.setDisplayMode(new DisplayMode());
}
}
I receive the error, "The import org cannot be resolved". Even though I've added the files to the build path config and I've added the native path in there as well. I've looked at this similar question and effectively tried every proposed solution. I've also tried deleting the project and reinstalling the dependencies. Here is my file tree for reference:
I'd be highly grateful if you could show me what I've done wrong. Thanks so much.
Edit 1:
I've discovered something interesting concerning the line:
Display.setDisplayMode(new DisplayMode());
While both Display and DisplayMode are underlined in red because the import is not working above, one of the "quick fixes" that comes up (even if I delete the import statements) is:
Import 'Display' (org.lwjgl.opengl)
Clicking this writes the import statement at the top (if it isn't there) or brings the cursor to it (if it is there). It then throws the aforementioned error. This seems to indicate that it does actually recognize the fact that the libraries are there, but for some reason can't import them.
The plot thickens.
Edit 2:
To check whether the problem is specifically to do with compatibility with lwjgl2 I've tried importing a class from another library (a linear algebra library called "jblas") with:
import org.jblas.Info;
...but once again I receive the same error. I guess this indicates that the problem is with the way that I am adding the scripts to the build path, with the software itself or a combination thereof.
To clarify how I put things on the build path:
Right click project name -> click "build path" -> click "configure build path" -> click "libraries" -> click on eiether "module path" or "class path" (I've tried both) -> click "add jars" -> navigate to my "lib" folder -> go inside "jars" folder -> select all the jars -> click "apply and close".
Edit 3:
I can import the built-in packages and I can import packages that I've made.
EDIT: DON'T DO THE FOLLOWING: LOOK AT THE EDIT
I downgraded my eclipse version to Oxygen, now I can import the packages without errors. Hopefully, this is remedied eventually so that I can move to the latest version of eclipse. Also, even in oxygen, it didn't work at first. I created a new project and reimported the various jars.
Edit: I faced this problem again, in oxygen
Fortunately this time I resolved it more quickly. I simply added the following snippet to my module-info.jar:
requires org.lwjgl;
Yep it was that simple.
was probably the problem the first time as well. This second problem arose from a second project I decided to make. The last project didn't have a module-info.jar.
That's why it allowed me to not write that line. Meanwhile, the original projects in eclipse 2018/19 did have the module-info.jar file and did have the problem. Maybe in Oxygen it just doesn't happen by default?

Programs run fine with LibGDX -desktop but not LibGDX - Android?

So I have just set up Eclipse to work with LibGDX using Gradle. After I installed I noticed there was a problem with the Android package, there was a red cross next to the package. When I opened it further there was a red cross next to src then com.myname.game.android and then in AndroidLauncher.java. When I opened the AndroidLauncher.java, this was the code I got:
package com.faturbansloth.game.android;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.faturbansloth.game.MyGame;
public class AndroidLauncher extends AndroidApplication {
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new MyGame(), config);
}
}
When I looked at the errors in he code of AndroidLauncher.java they were saying:
-The type android.os.Handler cannot be resolved. It is indirectly referenced from
required .class files
-The import android.os.Bundle cannot be resolved
-Multiple markers at this line
- The type android.app.Activity cannot be resolved. It is indirectly referenced from
required .class files
- The hierarchy of the type AndroidLauncher is inconsistent
-Bundle cannot be resolved to a type
I am using SDK Manager 22.6.2 with the newest Gradle plugin for Eclipse. I have JRE 8 and JDK 7. Is there anyway to fix this problem? Thanks in advance.
There was no Android Version selected by default, so go:
Project -> Properties -> Android -> Project Build Target and select your preferred version
I have no idea why this works but it does for me. I installed the ADT plugin, refreshed the android section and the red cross disappeared.
Refer to the section under "Download the ADT Plugin" to install the ADT plugin.
http://developer.android.com/sdk/installing/installing-adt.html
After that, go to Eclipse > Package Explorer > Left click on Project-android > Select Refresh.

Eclipse error ... cannot be resolved to a type

I have a dynamic web project that I am working on to migrate a jsp/servlet app from JRun to Tomcat.
I am getting the error: com.ibm.ivj.eab.dab.DatastoreJDBC cannot be resolved to a type.
I have the *.class files sitting inside a com/ibm/ivj/eab/dab folder (exactly how I found them). I have tried creating a jar file and adding that to the build path via "Add External Jar", I have also tried adding an "External Class Folder" and pointing to the folder that contains the "com" directory in question.
Still, the error persists. What is strange is if I start typing the package name eclipse actually auto-completes the class for me! (pictured below). Any ideas would be greatly appreciated. Maybe the classes were compiled for a much older java version and that is causing trouble? Maybe there is something I need to do to ensure the classes end up in the WEB-INF/lib directory?
I
Also If you are using mavenised project then try to update your project by clicking Alt+F5.
Or right click on the application and go to maven /update project.
It builds all your components and resolves if any import error is there.
Right click your project name.
Click Properties.
Click Java Build Path.
Click on Add Class Folder.
Then choose your class.
Alternatively, Add Jars should work although you claim that you attempted that.
Also, "have you tried turning it off and back on again"? (Restart Eclipse).
To solve the error "...cannot be resolved to a type.." do the followings:
Right click on the class and select "Build Path-->Exclude"
Again right click on the class and select "Build Path-->Include"
It works for me.
There are two ways to solve the issue "cannot be resolved to a type
":
For non maven project, add jars manually in a folder and add it in java build path. This would solve the compilation errors.
For maven project, right click on the project and go to maven -> update project. Select all the projects where you are getting compilation errors and also check "Force update of snapshots/releases". This will update the project and fix the compilation errors.
Project -> Clean
can at least sometimes be sufficient to resolve the matter.
For maven users:
Right click on the project
Maven
Update Project
Easy Solution:
Go to
Project property -> java builder path -> maven -> find c3p0-0.9.5.2.jar
and see the location where the file is stored in the local repository and go to this location and delete the repository manually.
Right click Project > Properties
Java Build Path > Add Class Folder
Select the bin folder
Click ok
Switch Order and Export tab
Select the newly added bin path move UP
Click Apply button
Solved the problem by dropping the jar into WEB_INF/lib.
copying the jar files will resolve. If by any chance you are copying the code from any tutorials, make sure the class names are spelled in correct case...for example i copied a code from one of the tutorials which had solr in S cap. Eclipse was continiously throwing the error and i also did a bit of googling ...everything was ok and it took 30 mins for me to realise the cap small issue. Am sure this will help someone
For many new users don't forget to add an asterisk (*) after your import statements if you wanna use all the classes in a package....for example
import java.io.*;
public class Learning
{
public static void main(String[] args)
{
BufferedInputStream sd = new BufferedInputStream(System.in);
// no error
}
}
================================================================
import java.io;
public class Learning
{
public static void main(String[] args)
{
BufferedInputStream sd = new BufferedInputStream(System.in);
// BufferedInputStream cannot be resolved to a type error
}
}
Solution :
1.Project -> Build Path -> Configure Build Path
2.Select Java Build path on the left menu, and select "Source"
3.Under Project select Include(All) and click OK
Cause :
The issue might because u might have deleted the CLASS files or dependencies on the project
Project -> Build Path -> Configure Build Path
Select Java Build path on the left menu, and select "Source"
click on Excluded and then Include(All) and then click OK
Cause : The issue might because u might have deleted the CLASS files
or dependencies on the project
For maven users:
Right click on the project
Maven
Update Project
First you need to update the pom.xml by adding below
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
1] Right click your project name.
2] Click Properties.
3] Click Java Build Path.
4] Check on 'Maven Dependencies' in Order and Export tabl.
In my case, previously it was not enabled. So when I enabled it my #GetMapping annotation works fine..
Also, there is the solution for IvyDE users. Right click on project -> Ivy -> resolve
It's necessary to set ivy.mirror property in build.properties
I just closed all the files and reopened them, and voila!!! Hope this helps someone in the future ;)
Download servlet-api.jar file and paste it in WEB-INF folder it will work

how to add plug in dependency in eclipse

I want to know why and how to add a plug in dependency for any project in eclipse.
Plug-in Dependencies from the Eclipse Documentation Archives
Hope this helps.
Click on the project , choose properties, go to Java Build Path .. add jars or add external jars should solve your problem.
How to Resolve What Plugin to Add to the Dependencies
I needed to know what dependency to add (to an Eclipse Plug-in) as well as how to add it. The errors I got in the Java code were:
The type org.eclipse.jface.text.source.Annotation cannot be resolved. It is indirectly referenced from required .class files
in the java 'package' statement and:
The hierarchy of the type JavaDecodePlugin is inconsistent
To find what plugin supplied the Annotation class I searched the 'plugins' directory of the where the Eclipse code was installed on my (windows) machine (\app\androidDev\eclipse) for a reference to that class:
C:\app\androidDev\eclipse\plugins>grep -r org.eclipse.jface.text.source.Annotation *
Binary file org.eclipse.jface.text_3.8.2.v20121126-164145.jar matches
Binary file org.eclipse.text_3.5.200.v20120523-1310.jar matches
it was referenced in two plugins/jars. I searched the jars for the desired class. The first plugin/jar didn't contain it, the second did.
C:\app\androidDev\eclipse\plugins>jar -tf org.eclipse.jface.text_3.8.2.v20121126-164145.jar |grep Annotations
org/eclipse/jface/text/link/LinkedPositionAnnotations.class
org/eclipse/jface/text/source/projection/ProjectionSupport$ProjectionAnnotationsPainter.class
C:\app\androidDev\eclipse\plugins>jar -tf org.eclipse.text_3.5.200.v20120523-1310.jar |grep Annotations
org/eclipse/jface/text/source/Annotation.class
org/eclipse/jface/text/source/AnnotationMap.class
org/eclipse/jface/text/source/AnnotationModel$1.class
org/eclipse/jface/text/source/AnnotationModel$2.class
org/eclipse/jface/text/source/AnnotationModel$AnnotationsInterator.class
org/eclipse/jface/text/source/AnnotationModel$InternalModelListener.class
org/eclipse/jface/text/source/AnnotationModel$MetaIterator.class
org/eclipse/jface/text/source/AnnotationModel$RegionIterator.class
org/eclipse/jface/text/source/AnnotationModel.class
org/eclipse/jface/text/source/AnnotationModelEvent.class
So I knew what plugin I needed now. As Plug-in Dependencies shows (as in the answer above) You need to go to 'Package Explorer' expand 'META-INF', open 'MANIFEST.MF', open the 'Dependencies' tab and click the 'Add' button on the 'Required Plug-ins' section, type part of the name of the plug-in in the 'Select a Plug-in text area, let it find the fullname of the plugin (perhaps select the desired plugin) and click Ok.
(This answer is somewhat to document the process so if I have to do this again after I forget what I did, I, and you, will know)

Categories

Resources