I have a working java project (in ubuntu 12.04LTS, configured and compiled using ant). Is there a way I can configure and run it in Eclipse? Every time I try to load it in eclipse it gives a bunch of errors because of packages not being where its expecting I guess. Also, it will help if you could tell whats build path. I'm using Eclipse Java EE IDE Kepler Release.
My project structure looks like this:
project
build.xml
build.properties
build.common
projFolder - proj code, 3rd party lib/bin/src,
commons - proj code, ui code, 3rd party lib and binaries
dist - has a bunch of scripts and jars and may be some binaries
And how I got my project in Eclipse (this is probably not the most efficient way to have the project running in Eclipse, not sure)
I did new->java project then enter project name, unchecked 'use default location' and provided the location of my project so it imported my project in eclipse. then in my classes i have all the errors (red cross at the display) and it says imports cannot be resolved, objects can't be resolved to a type and such.
import com.psid.codedata.projects.TProjectDRD;
import com.psid.codedata.projects.TProjectsDRD;
error on above imports:
The import cannot be resolved
It probably needs you to add all your source folders to the build path:
Right-click on your project and select Properties,
Along the left-hand side click "Java Build Path",
Click the "Source" tab if it isn't already selected,
Click the "Add Folder..." button on the right-hand side,
Select whatever your source folders are in projFolder and commons,
Click the "Libraries" tab,
Click the "Add JARs..." button on the right-hand side,
Select whatever your libraries are in projFolder, commons and dist,
Click the "OK" button.
Note that "New -> Java project" is for creating a brand new, empty project. Since you want to create an Eclipse project from an existing project with an Ant script, you should select the appropriate selection under the "Ant" subsection in the New Project dialog. See this answer to a related SO question for details.
add this line to nbproject/project.properties:
j2ee.server.home=http://localhost
Related
A Java 7 project in NetBeans 8.0 which compiles and runs fine is not able to generate Javadoc pages without throwing the error Package packagename does not exist in reference to a supporting package which is part of another project.
This happens even though the current project includes the supporting project as a library, which can be seen by right-clicking on the current project and selecting Properties, then selecting the Libraries category on the left, and checking that the supporting project is listed under the Compile tab as one of the "Compile-time Libraries".
In NetBeans 8.0, with the current project open, go to the Run menu and then select Clean and Build Project (ProjectName) or use the keyboard shortcut Shift+F11.
Once the project has been cleaned out and rebuilt, then go to the Run menu and select Generate Javadoc (ProjectName). The generator should now be able to find the supporting project and the Javadoc pages should be generated without any errors about the existence of the required package.
Try out this. It helped me.
Right Click on a package in your project
Go to tools, then
Select Analyse Javadoc.
Tick all the checkboxes and
Select fix selected.
After you are done, do the same for the rest of the packages.
Now go ahead and run Generate javadoc.
I am a computer science student learning Java, so I do some work at home and at college on a mixture of Linux and Windows. I have a problem after copying a new project into the Eclipse workspace. The project shows up, but with a red exclamation mark and an error saying:
The project cannot be built until build path errors are resolved
How can I fix this? I tried the solution described here, but it didn't work.
Identify "project navigator" or "package explorer" view.
Right click on your project, select Build Path --> Configure build Path.
In the emerging window, you will find four tabs, select "Libraries".There, under "Web app libraries" (expand it), you will see the libraries added to the project's classpath. Check if all of them are available. If one or more are not (they'll have "missing" beside their name and a red mark on their icon), check if you need them (perhaps you don't); if you don't need them, remove it, if you need them, exit this window, look out for the missing jar and IMPORT it into your project.
Open the Problems view. You can open this view by clicking on the small + sign at the left hand bottom corner of eclipse. It's a very tiny plus with a rectangle around it. Click on it and select problems.
The problem view will show you the problems that need to be resolved.
If the message says "the project is missing the required libraries...", you need to configure your build path by right clicking on your project, selecting properties, then build path. Add the required jar files using the libraries tab.
-If there are other problems other than missing libraries, you need to post the exact problems here to get a precise solution.
If you can't find the build path error, sometimes menu Project → Clean... works like a charm.
In my case, all libraries in the build path were OK.
To solve it, I deleted all project metadata (.project, .classpath, .settings) and re-imported the project as a Maven project.
Right click your Project > Properties > Java Build Path > Libraries
Remove the file with red "X" (something like JRE...)
Add Library
That's how I solved my problem.
I also had this problem in my system, but after looking inside the project I saw the XML structure of the .classpath file in the project path was incorrect. After amending that file the problem was solved.
If not working in any case...then delete your project from the Eclipse workspace and again import as a Maven project if that is a Maven project. Else import as an existing project.
I tried all the previous given solutions, but they didn't work, but it works for me.
In Eclipse, go to Build Path, click "Add Library", select JRE System Library, click "Next", select option "Workspace default JRE(i)", and click "Finish".
This worked for me.
Go to Project > Properties > Java Compiler > Building
Look under Build Path Problems
Un-check "Abort build when build path error occurs"
It won't solve all your errors but at least it will let you run your program :)
I have a Java Project in Eclipse, and a Java Dynamic Web Project in Eclipse. In the former, all the jar files are shown individually under the top-level project folder. In the latter, the jar files are under a Libraries folder and the navigation is more convenient.
Is it possible to organize them in the same way in the Java Project also? If so, how?
Update: It is the Project Explorer View. For the Java Project, I see: "my_project_name" with the arrow expanded to point downwards, then I see: "package_icon src/main/java" and below that "package_icon src/main/resources" and then 20 jar files one below the other: "jar_icon activation-1.1.jar", ...
For the Java Dynamic Web Project I see: "my_project_name" as above, then I see: "JAX-WS Web Services" (unexpanded), then "Deployment Descriptor" (unexpanded), then "Java Resources" which I have expandeded, so I see the components of it below, of which the first is: "package_icon src/main/java", then below it, "package_icon src/main/resources", then below it "libraries_icon Libraries" instead of 20 jars! I have the option of expanding Libraries if I really need to see the 20 jars.
The only option I found to make things prettier in Eclipse Kepler is to:
In the Project Explorer window there is a down arrow in the upper right corner. Select that and then Customize View.
Select 'Libraries from external' and then OK.
Kind of cheesy...
EDIT: Of course I had to go and do some more digging...and it looks like I'll have to try this and see how it works.
Similar to M Miller's answer (but for Juno), click Show 'Referenced Libraries' Node in the dropdown of the Package Explorer window:
I'm using:
Eclipse IDE for Java Developers
Version: Juno Release
Build id: 20120614-1722
I noticed this "feature" on Eclipse Juno (latest version), when you have a jar file added to the build path it is not shown as a single file on the project.
Try removing one of the jars from the build path to see if it shows up again.
I couldn't find how to turn it off though.
BTW... the project layout for your "Java Project" is more akin to a "Maven Project", which is a bit more powerful.
You should change into the Package Explorer by Window > show View. It will display all the referenced libraries in a Referenced Libraries folder.
I have a Java Project & Map/Reducer Project in eclipse Workspace, I want to use a class file of Map/Reducer Project from java project to perform computation, I am new to Apache Hadoop & Map/Reducer thing, please Suggest.
If a hadoop project is just like a Java project (and it probably is); right click on the other project in the package explorer, select properties, and then choose java build path. After that, click on the projects tab and select the add button. A dialog box should come up, and you should be able to select your hadoop project.
Both projects must be in the workspace, of course.
Is it possible to import an existing Java project which is in my workspace, in an Android project which is also in my workspace? The Java project doesn't use stuff that is incompatible with Android. I could do it using a .JAR, but since I'm modifying the Java project a lot, I would like to import the whole source code and change it once in a while. Is it possible? Thanks
This is somewhat of a hack, but worked for my project:
Add both Android project and plain Java project to workspace
Go to properties for Android project -> Java Build Path -> Source
Click Link Source, in "Folder name", make sure to select the root directory of the plain Java project's src tree
Use a descriptive name for "Linked folder location", like "java_project_src".
Press Finish and compile
This setup will compile the plain-java code as Dalvik bytecode. In my case, I had pure java code with very limited dependencies, but wanted to share the pure java code with non-Android projects, instead of separately maintaining these files in every project.
I think you are talking about referencing other projects into the current project, if this is the case then you can do this by Right click on project, properties->Project Reference.
You can link another projects to your current project. Right click on your main project, choose Build Path -> Configure Build Path... In the dialog choose the Projects tab, then click Add.. button. Now choose the project you want to link and click OK. You'll now be able to use this project's sources inside your main project. Hope this helps.