I'm debugging my application and I see that I have an exception in jar file which is built from completely separate Java project. I checked out this project from SVN.
How can I attach this project in Eclipse to my current project and debug this code as well?
You'll have to create a dependency of one project on the other.
Right Click on your project name > Properties > Java Build Path > Projects
Just make sure that both projects are in the same workspace.
Related
I created a gradle project in Intellij idea. After building and running everything worked as expected. But I don't want to run an IDE everytime I need to use my program. Can anyone recommend a step-by- step guide?
You can quickly do it in IntelliJ following theses steps :
Go to File > Project Structure
Select Artifacts tab and click on the "+" icon
Choose to generate a JAR from modules with dependencies
Choose your module and its main class and save changes
Now go to Build > build artifacts > build*
It's done, your executable .jar file should be located in out/artifacts/module_name/module.jar
*Choose rebuild if it has already been built.
I have a fundamental question, but something which bothers me a lot. We sync code from perforce in my company. and then we are taught to build the code compatible to eclipse. Then we import the code in eclipse as existing project. Then when we hit ctrl-space from an object, we get suggestions of methods.
My question is: Why do we need to build the code for suggestions of methods? . After syncing from perforce, what I have is still an existing java project (right?). So eclipse should be smart enough to be able to index and find out from source code, the methods, when I hit ctrl-space on an object?.
Why do I need to build? What purpose the build serves?
The code does not have to be built, but to be able to import a directory as project via File > Import...: General > Existing Projects into Workspace into Eclipse, at least the file .project must exist.
There are several ways to import, for example, a Maven project:
Execute mvn eclipse:eclipse on the command line and in Eclipse do File > Import...: General > Existing Projects into Workspace
File > Import...: Maven > Existing Maven Projects without a command line call uses by default the in Eclipse embedded Maven
File > Open Projects from File System... (or in Git Repositories view right-click + Import Projects...) detects not only Maven projects but also plain Java projects and automatically configures them accordingly.
In all three ways the following files are created, which are required in Eclipse for the Java content assist (Ctrl+Space) to work:
.project - says whether it is e. g. a Java, a PHP or a C/C++ project (to be more precise, the project name, builders and natures are specified here, e. g. the project folder icon of a Java Maven project will be decorated with a M and a J based on the Java and Maven project natures)
.classpath - tells Eclipse where the source and output folders are and which JARs should be added to the classpath (in Maven projects, the JARs are not listed, but it refers to the Maven dependencies which are computed from the pom.xml file)
.settings/org.eclipse.jdt.core.prefs - contains Java compiler and optional formatter settings (e. g. which Java version; which problems should be ignored or shown as infos, as warnings or as errors, etc.)
With Eclipse Oomph you can automate even more: you select a project and based on a project-specific configuration, for example, a Git repository is automatically cloned and plug-ins necessary to edit the project are automatically installed and configured.
Eclipse uses relfection for the suggestion, it can be possible only if the .class file generated
Eclipse automatically adds everything in WEB-INF/lib (specified in deployment assembly) to the project's build path. Is there a way to override this behavior? I need for another project jar to be deployed and available at run time but not have a forced compile-time dependency on it. Thanks!
Go to the properties window of the project. Then go to java build path tab and remove the relevant other project from libraries there. Then go to projects in the same tab and select the required project by using the add option and add it. Then restart Eclipse.
I'm switching to Intellij and trying to do the same thing as in Eclipse. In Eclipse, you can add a project as a dependency in another project (project properties -> "Java Build Path" -> "Projects" -> Click on my library project).
The current situation is that I'm developing a library and I can test the features in another project without building the jar file every time I add new stuff to the library.
I'm trying to achieve this with Intellij but without success (the projects are both imported in Intellij).
How can I do that?
File > Project Structure. Then choose your module, and add any dependency, either Jar, Library or Module:
Larger image here: http://i.imgur.com/rjdxJHx.png
From File -> project structure, select Modules. You will be presented with all the added projects. Click a project and from the right hand side select Dependencies tab. This will show you projects that are not imported in red coloured text. HTH
File > Project Structure > Project Settings > Modules
Add the module you want to add as dependency.
Add your module dependency in your project.
If you use Maven you'll see the following message:
Module 'your-module' is imported from Maven. Any changes made in its
configuration may be lost after reimporting.
→ Add your project to your pom.xml
If you don't do that, your dependency will be removed each time you reimport/refresh maven projects.
I am a newbie at J2ME. Recently, I've shifted from Netbeans to Eclipse because of some internal constraints.
I am making an App which makes use of a user-defined library. This library has only a jar file.
Now, in Netbeans there were no problems. But in eclipse, I am unable to access the classes defined in the jar file included in my library. The exception thrown is java.lang.NoClassDefFoundError.
What should I do?
Have you added the jar through:
right click your project > Build Path > Configure Build Path > Add External Jars and select your jar from there?
In case the jar is in your project dir, you can use "Add Jars" (not External).
I assume you have done it, so to the next step:
How are you running your application? In the Run Configurations there is a classpath tab - make sure your jar is present there as well.