I have a new Android project that I am trying to build with Maven.
I was able to download and import the project in Eclipse, but I am unable to generate a new class inside the the src directory.
The warning I get from File -> New -> Class is : Source folder is not a Java project.
I found a couple of solutions on the internet, saying that it is necessary to include Java from the project facets, but there is no Java option on the tab.
Any solution to this? I am working on Arch Linux.
The solution is adding the Maven Java EE plugin to Eclipse. I found this by typing "facets" in the Market Place search field. This plugin came up and I gave it a go. Luckily, it worked.
After this, you can find several options in project facets. Choose Java :
Properties -> Project Facets -> Java
This site here pointed me into the right direction and explains the process in more detail: Source Folder is not a Java Project
Related
I have a Java web project done by another team, that is hosted on a Tomcat. I am asked to do some modification in the project.
Modifying JSP- and HTML-files is fine, but when it comes to modifying an existing Java-file, I need to import the full project to some IDE like Eclipse. How can I import the full project?
Please follow the steps below to import an existing JAVA project:
Copy the java project to your workspace (ex. C:/workspace)
Go to Eclipse IDE
Navigate to File->New->Java Project
A dialog box will display. Enter the exact name (case-sensitive) to the Project Name field.
The Location field value should be where the project is currently located (ex. C:/workspace/MyProject)
Click Finish.
The project should now be displayed in the Package Explorer panel (or Project Explorer).
Note: If the project is Web, you should choose File->New->Dynamic Web Project.
Check with the other team what IDE they use. Usually the project might also contain IDE files (.project & .classpath) for Eclipse given you have access to the source code.
If not, create a new Project (using the Java EE edition) and look at the directory structure for some sample projects. You should then be able to create the structure in your new project accordingly.
I having trouble on the setup of drools I already tried this tutorial to setup my drools and it seems doesn't work for me then what i tried next is to go to marketplace and install the plugin from there, from there I'm able to open the perspective that means i already install the plugin on my eclipse.
Not I'm trying to create a drool project to see the example included to the project but the project doesn't have the Drool Library
That also make the imports to error, what am i doing wrong?
If you followed the tutorial, chapter 8.2, normally the Drools plugin would add the Drools library to your new rule project.
If that doesn't work, you can always add the Drools library to the build path of your project via Eclipse. Right click on your project -> properties -> Java Build Path -> tab Libraries -> Add library (or add external jar and add the Drools.jar's manuallly)
Using Eclipse (juno) and GAE plugin, I've compiled and ran the "guestbook" example (https://developers.google.com/appengine/docs/java/gettingstarted/creating) without any problem.
Both of the class of the example extend "HttpServlet" class of javax.servlet.http package.
I'd like to see the source code (and javadoc) of this class and of the other class of the package (and super package), but I can't figure out where they are.
They are not in
Program Files\eclipse-jee-juno-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.0\appengine-java-sdk-1.7.0\src
(I've tried all of the files in there)
Binary files should be in servlet-api.jar in
Program Files\eclipse-jee-juno-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.0\appengine-java-sdk-1.7.0\lib\shared
I've googled a lot without success.
Anybody knows where to find sources of javax.servlet package?
Thanks a lot.
The sources for javax classes are included with Java EE distributions and not the App Engine SDK. If you can't find a local Java EE distribution, you can try downloading the sources here, and referencing them from within Eclipse.
Project properties -> configure build path -> libraries -> drop down arrow of App Engine SDK-> drop down arrow of servlet-api.jar -> click javadoc location -> click edit -> enter javadoc URL : http://docs.oracle.com/javaee/6/api/
I am using Eclipse to develop an Android board game.
I have developed the UI in an Android project.
On the other hand, I have developed the AI in a regular Java project, because I wanted to be able to test it without all the constraints of the Android emulator (I didn't find any other way to run the code using my Windows JVM).
Now comes the times when I want to 'join' both projects (which work fine independently), that is to use the AI Java classes from the UI.
This is what I have tried:
In my Android project Properties > Projects References, I ticked the Java project.
This allows me to build without error the Android project (which instantiates an AI object).
But it fails at runtime with this error:
Could not find class 'my.package.AI', referenced from method my.otherpackage.UI.onStart
What would be the correct way to include the AI Java Project into my Android Project ?
(NB: I still want to be able to develop and test the AI as a regular Java app, so I think using a jar or copying all the sources to the Android Project would not suit my needs)
EDIT:
I was hoping that the new ADT v17 would solve the problem, but it didn't. I have tried virtually every option available to include a project in my Android project:
Adding or linking a source folder
Adding a Project (Java Build Path > Projects tab)
Adding a Class Folder or a Library (Java Build Path > Library tab)
Ticking all the previously imported projets/libraries as Exported
The only way that allows compiling and running without error is adding the JAR of the Java Project to the Android project build path.
Projects References only add the dependent project source code (your AI project) as a soft (perhaps weak is a more accurate word) reference, your AI project is not added into you Android Project Build path. so the actual ai.jar is not exported into the final apk when Eclipse build your app.
You should add AI project into Android project build path:
Right-click on your android project, select Build Path - Configure Build Path, in Projects tab (Required projects on the build path), add your AI project here.
Then in Order and Export tab (Build class path order and exported entries), tick your newly added AI project appeared int the list.
Step 2 is probably optional, this should add AI project as a reference in Android project and export the ai.jar to final.apk when Eclipse build your Android project.
Update from ADT 17.0.0:
Android Dev Team just release SDK r17 with ADT 17.0.0, which claims to handle this use cases properly now:
Eclipse specific changes
The dynamic classpath container called “Library Projects” has been renamed to “Android Dependencies” as it now contains more than just Library Projects.
The container will now also be populated with Java-only projects that are referenced by Library Projects. If those Java projects also reference other Java projects and/or jar files they will be added automatically (jar files referenced through user libraries are supported as well).
Important: this only happens if the references are set to be exported in the referencing project. Note that this is not the default when adding a project or jar file to a project build path.
Library Projects (and the content of their libs/*.jar files) is always exported. This change only impacts Java-only projects and their own jar files.
Again, duplicates (both projects and jar files) are detected and removed.
More in this link.
Edit: After much testing, reading and found my solution. Problem is (as of this writing) that you can't reference another project from an Android project, although it works fine for a normal Java application project.
Workaround for me (Windows with NTFS filesystem):
In a prompt (admin rights) make a symbolic folder link using mklink /D command pointing to your source project folders, and refresh in Eclipse as needed.
The obvious limitation is you cant use the same package names in source project and target project, and then there is the problem with libs in the common project.
example:
cd \java\workspace\AndroidProject\src\your\package
mklink /D common c:\java\workspace\CommonProject\src\your\package\common
Clarification: You can reference another project from an Android project to make it compile, however when you run, the referenced classes from the included project are not put in the apk classes.dex (verified with dex decompiler).
Using ADT 21.0.0 64bit on Windows 7 64bit. I tried adding project to build path. Ticked in the Order and Export, played with order. I read the official solution, the detailed explanation of that solution, exported as JAR, added to libs. Did not work, while the source was without errors. Read in the comments that the solution didn't work for everyone.
Was fed up with it and tried a simple but somewhat messier solution: linked the Java project's source to the Android project. That did the trick. Hope that this will help others too.
Don't add it to the project references area, instead go into the Android pane (in the Project Properties), scroll down to the bottom, and add it under Libraries.
This sometimes works but sometimes produces bizarre Eclipse issues (not sure why), in which case copying the jar directly into the project seems to work best.
I just downloaded a Google App Engine sample Java project. I am trying to import it into eclipse. If I chose file/import/existing projects into workspace, and navigate to the appropriate directory, it doesn't find any projects. I'm speculating this means that dotmatrix is not an Eclipse project. How can I import it?
Thanks.
Project you are trying to import doesn't seem like Eclipse Project.
You can still use this project in Eclipse as Java project by following these steps:
Open Java Perspective in Eclipse.
Right Click in Package explorer pane and select New >> Java Project.
Give appropriate name to your Project and click the option that says "Create project from existing sources."
Select root dir of project downloaded and click finish.
Note: You may need to configure source folders, library and other build paths to complete setup.