I am not having any luck searching for a solution to this problem.
I work with a team that uses Eclipse for the java IDE, and gradle for the project build. We are developing on a linux distro.
One of the Java projects needs to use library jar files that gradle pulls down into the {homedir}/.gradle/cache directory tree.
How do I setup the project Build Path in eclipse, and the .classpath file it generates, to use a home directory variable ({HOMEDIR_VAR}/.gradle/cache/...), instead of hard-coding my home directory (/home/{myusername}/.gradle/cache/...)?
It is usually a good practice to not commit IDE specific project files to version control. Modern build tools (Maven, Gradle) integrate nicely with IDEs like Eclipse, IntelliJ IDEA and Netbeans to generate those artifacts for you.
In short, let Gradle build the Eclipse class path for you. That is either via
Buildship (Using the Gradle build system in the Eclipse IDE - Tutorial), the official Eclipse plugin to integrate with the Gradle build system. Easy to use and you can directly import Gradle projects into Eclipse.
Gradle Eclipse Plugin, a Gradle plugin that generates required Eclipse project files.
There's no need to fiddle with the class path manually anymore. However, if for somewhat reason this doesn't work out for you, there's a workaround: It is possible to relocate the Gradle home directory and with that the cache directory to a static path. This can be done for example by defining the environment variable GRADLE_USER_HOME (Gradle Goodness: Changing the Gradle User Home Directory). With that, it's possible to maintain the Eclipse class path manually and share it with your team.
Related
I am having an issue that I am trying to solve.
I have a java project and I use intelij IDE.
I want to move it to another computer.
I used to work with eclipse and this task was very easy, export as zip and import and open zip.
However in intelij there is no way to do it, it is not support zip.
I searched all the web, and nothing, all the solutions are with git.
all the information on youtube and so are just to import project to intelij, or to export as jar and run the project.
what is the easiest way without using the internet to export project from one intelij using disk on key, and open it and start working on another computer with intelij.
Can anyone provide step by step solution for this question.
I am using 2019 IDE community version
regards
Well the answer is "it depends." For many maven projects, the IDE files are not checked in. When you get a new machine, clone the repo and import the project. Yes, you start from scratch, but it is easy. From the IDE, you may have to manually select Java, and setup Maven. Again this depends. Some projects use bundled Java and Maven, and other groups manually install specific versions. So as I said, it depends upon the project.
With Intellij, projects can generally be copied from one directory to another. This means that the paths in the IntelliJ iml files use relative paths.
So this is really a build question. Personally, I want to be able to build from source control. I will check in Intellij runtime configurations, but have git ignore other IDE files.
Perhaps you could clarify what issues you have building from freshly cloned repo.
When you create projects you specify the location where they will reside. By default IntelliJ IDEA suggests a directory under C:\Users\\IdeaProjects.
You can copy the project folder (as to export it).
To open a project, you can right click on a project folder and open it as a Java project on IntelliJ IDEA (or) On the IntelliJ IDEA, import the project folder.
I'm kind of new to Eclipse and I'm hating it so far
The question is I'm working on a small project with some classmates, we are using Eclipse and Git but every time someone does an immport all the libraries are lost because they are referencing the computers path like C:/someone/something.jar and then someone else push something to github and the libraries path C:/someone2/somthing.jar
Every time, I and my partners have to search for the libraries on our pc so the errors stop appearing.
Is there an easier way so we don't have to lose time searching for the libraries on our pc?
You need Java build tool like Maven, Gradle to manage your dependencies.
In that way, it will resolve the libraries for you. And in the source code, you should not check in .classpath,.project meta files. Those files should be added into .gitignore to avoid commit.
To import projects into IDE (Eclipse in your case), Maven and Gradle can help you to generate those IDE meta files. Or some Eclipse plugins could be used to import maven or gradle project.
You should create a folder for libraries and put all jar files in there, add these files to classpath using Java Build Path Option from project properties. Also add this folder to git
I am using Eclipse Kepler for Java. Normally you can add internal/external .jars to a Java project in the build path located in the properties. Why, when I clone a git repo and import it into my projects, do I lose that ability? I don't understand. I kinda need to do that.
This is probably because the .gitignore has been configured to ignore .jar
Open the .gitignore file and remove the line *.jar, you should be able to add it.
======
As an aside - usually, for Java projects .jar files are not committed to repository (as they are large & it can slow down repository cloning), instead maven or gradle is used to configure dependencies. Example - http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/
Then when you want to work with eclipse just run mvn eclipse:eclipse to generate the necessary files. .gitgnore is usually set up to ignore *.class, *.jar, .project, .settings, .classpath
I found that if you open the run configurations and go to the Classpath tab that you can add internal/external .jars. The run configuration can be accessed by clicking Run > Run configurations. I added my .jar to the user entries. The bootstrap entry caused a null pointer.
When a project relies on libraries/modules, it's best to use a build tool for dependency management. JVM ecosystem is dominated with three build tools: Gradle, Maven and Ant.
How it works:
In a build script we declare dependencies of the project. This tells the build tool where to retrieve libraries/modules our project depends on. Dependencies are resolved at runtime; downloaded from a remote repository, retrieved from a local directory or if required another project to be built in a multi-project setting.
I am a novice and don't have much idea. So I have a library that is built with Maven and I want to include this library in my java project in Eclipse, how do I do this? I am using Eclipse juno on MacOSx. I want to run one of the modules in this library, so the source code is provided for this module but how do i run this?
If you are not using maven, you have to download the jar and the sources of that jar (In your case, you can download the zip file provided on the website you mention : http://code.google.com/p/cleartk/downloads/list ) and put it somewhere on your computer.
Then you have to set the build path of your project in Eclipse :
Right-click on your project -> Properties -> Java Build Path
Then you can click on the Libraries tab and Add External Jars so you can point to the jar you downloaded.
In this tab, you can attach the sources of this jar to have access to the source code in Eclipse (and eventually set breakpoint).
I have a plain Java project (not a plugin project) which I want to add to a classpath of a eclipse plugin which I am developing. But in web projects I can add that project as a build path and it works fine. But I tried same thing in eclipse plugin, I am able to compile successfully, but at run time I am getting java.lang.ClassNotFoundException.
I know OSGi quite well and I know how to add OSGi into an classpath (using export-packages) but what I want is to add Standard, non-osgi project into an classpath, so that I wont' get runtime errors. Is there anyway I can achieve this?
I can export project as a jar file or make it as a plugin project and it would work fine. But that's not my option currently because, still that API is in pre-alpha stage, and there would be lot of changes going on. So I am trying to avoid pain of exporting it as jar file everytime. Is there any option for me other than this?
I have a similar situation: I want non-OSGi Maven dependencies integrated into the classpath of my plugin. I succeeded with a roundabout solution, which I think is the best I could get.
I have a build step outside of Eclipse where I copy the class files of the dependency into the plugin's lib folder. The lib folder is specified in MANIFEST.MF as an entry in Bundle-ClassPath and (here comes the hack) as a source folder in build.properties. That was the only way to make the plugin work both when launched from within Eclipse and when exported.