Eclipse: reference sources from other project - java

I've got two projects in Eclipse. Both have some source files, and I want to reference sources from one project in another one. The only thing that works is
Project Properties -> Java build path -> Projects
Where I add the required project.
The problem is that when I'm trying to launch the project1 activity it starts and then launches project2 default activity.
How could I add sources from another project?

If you want to use another project as an library in your Android project add the project via Project Properties --> Android --> Library. The referenced project should be marked 'Is Library' on their own properties page.

Related

Eclipse I can't link project B to project A

I work with Eclipse. I have two projects in the workspace. This is my Eclipse navigator.
I want to add AR04.CME to cmeWeb.
Folder cmeShare has some jar which I need in cmeWeb.
I click in cmeWeb properties ->Java Build Path -> Projects
This is the screen
AR04.CME doesn't appear as project.
How can I add this project?
Linking Project A to another Project B is useful when you have source code in A that you want to share to B. That's not your case. You don't seem to share source code, but a compiled library instead.
Your best option is to edit cmeWeb's Build Classpath > libraries > add jar > select your Jar library.

Can't call a class from another git project in Eclipse

I imported a project from github into Eclipse (project A), using these steps: Importing a GitHub project into Eclipse
I have another app engine project I am building in Eclipse (project B). I would like to import a class from the project A to project B. I was trying to follow these steps: How can I refer to a class from another project in the same Workspace in Eclipse/Java
But when I go to project B's Java build path --> Projects --> Add, the select project window does not show the imported github project.
If I create another local Java project (project C), I can see project C as an option to add to project B's build path.
Make sure you are copied project A into your workspace while import into eclipse.
There is a check box option for copy project into workspace in eclipse import project.
First, You will have to fix the project A at eclipse before importing into the project B... By fixing, I mean setup the source paths of the project A (example, the folder src/com/google, should be a source folder at the project A configuration)... The Project A must compile (if the project A cannot be compiled by eclipse, I doubt that you will have success at importing it into project B)
Another strategy would be use the ant script of the project A and import, as java library, the artecfacts generated by those ANT files into the project B.

Eclipse workspace equivalent in IntelliJ?

It is said in IntelliJ IDEA Q&A for Eclipse Users that Eclipse Workspace is equivalent to "project" in IntelliJ terms, while Eclipse's project is equivalent to IntelliJ's module.
But after I created a project untitled and then created module untitled2 I got the following picture
I would think untitled is a project and untitled2 is a module, but both has src subfolders and listed in
so, both are modules of different level. Is this correct?
Is it possible to create module untitled3 at the same level as untitled?
How to create several modules of the same level without topmost one?
If you want to simulate the Eclipse workflow, you should create an empty project (~ workspace) first:
New Project > Empty Project
Now you can create separate modules (~ projects) to be shown exactly like you want:
You could also select untitled2, press F6 (Refactor > Move) and move it one level up in your directory. While creating untitled3 you can specify the folder for your module (use IdeaProjects instead of untitled).
The workspace equivalent term refers to Project Window in intellij. It will consists of modules which are equivalent of individual projects in Eclipse.
EDIT: You can right click on untitled module and go to Open Module Settings. And select Modules in project settings. With + sign you can choose to create new module. This should create new module on same level as untitled
All the information you need is here. JetBrains has a wonderful guide called "Working with modules".
Modules can be created on any level and any location, regardless the project location. You can safely remove the "parent" module.

add other projects as library in netbeans

I have a project A (for example an Ant based Java Application project) and a second project B (a Java Class Library project or another Java Application project, both Ant build based.)
Project B has some additional Java library dependencies (.jar files in the Libraries folder).
A depends on B. A can use classes which are written by myself in B but it can not see classes in the additional libraries of B unless I add those libraries/jar files to A.
Is there a way to get NetBeans to automatically manage the library dependencies in A by including the dependencies of B in addition to B's own jar file? In eclipse when you add .jar files to project B, it is not necessary to add them to A again.
Thanks.
In your project folder you should see a folder called Dependencies, right click on that folder and choose Add Dependency.... Open the Open Projects tab; from there you can select your project from the list. Click Add.
This works for NetBeans IDE 7.2.1.
The simpler NetBeans Ant project Libraries folder is used for compile time and run time dependencies of each individual project. If your "Java Class Library" type Ant based project B has additional library dependencies, they are not automatically forwarded or updated in Project A when you include B as a library of A.
When project A is built, it's .jar file will only contain Project A code and the lib/ folder will only include .jar files from it's Libraries folder. This can cause confusion when you upgrade the dependent library versions and possibly forget to upgrade them everywhere you depend on project B.
You will need to manually manage the dependencies unless you switch to a project management and build system that handles this, like Maven.
A NetBeans Maven project will have a Dependencies folder instead of a Libraries folder and if project B is properly setup and registered as a Maven project and project A is also created as a Maven project, you could Add Dependency on B to A and B would forward it's dependency information to Maven project A.
If you want to add another project as a library in netbeans right click on the libraries directory and select "Add Project", select the project you want to add. When you do this the jar file(in the dist dir) that has been built for the project you are adding will be selected and then click the "Add Project jar files" and that should add the jar file to your project. Alternatively you could select "Add Jar" instead and add the jar file yourself the way that Ravi described.
In your project folder you see a folder called Libraries , right click on that folder from there you can select your .jar file. You need not to add .jar files repeatedly after adding once to your project. You just need to Clean and Build your project whenever new files are added to .jar file.

creating project in eclipse

I want to create a project in eclipse in which the following directory gets generated automatically.
src/
tests/
projects.xml
meta-src/
So under which category this project will be falling. I was creating maven project. But it will be having lot more directories. So is there any specific project under which this will be falling? Or I can simply do Java project and keep on adding necessay files and directories?
Java project should be fine, you can set up auto-save actions etc no matter what the project type I believe.

Categories

Resources