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
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'll start this off by saying that I'm not a Java dev, I work in a .NET software house, but somehow we have ended up needing to modify some legacy java code.
So I have a project which I've opened up with IntelliJ IDEA Ultimate 2016.2. As far as I can tell this doesn't use Maven or Gradle or any other dependency management tool, and as I have no idea what I'm doing with Java projects I'm not going to start trying to understand that now.
I'm trying to add the Amazon AWS SDK to my project so I can upload some files to an S3 bucket. I've downloaded the SDK from the AWS site, and extracted the jar files into the lib folder of my project root. I've tried numerous ways of adding these as dependencies, right click the jar files and add as library, go into settings, modules, dependencies, click the plus and add the jars etc. When I build the project it builds fine, and intellisense if picking up the classes and methods when writing the code to utilise the SDK.
However, as soon as I run the app, I get a "java.lang.NoClassDefFound" for the com/amazonaws/AmazonServiceException package as the containing class is instantiated.
This could well be something to do with the "CLASSPATH" that I hear so much about (but don't fully understand), but my understanding was that IntelliJ handled this when adding the jars as a dependency. I've also tried adding all the jars from the "third-party" directory from the downloaded AWS zip file, and adding those as dependencies as well, but it still doesn't want to work.
Incidentally, I'm adding the jars to the lib folder so they are included in source control.
Any suggestions on how to use the AWS SDK without using Maven or Gradle?
Cheers
What I've done is to manually add all the jar files into the External Libraries.
Go to File > Project Structure
In the left window pane, choose Modules under Project Settings
Click on the Dependencies tab
Click on the + sign and select 1 JARs or Directories
Navigate to the folders containing the jar files (include third-party dependecies also) and click OK
See My IntelliJ screenshot
I have inherited an old java project, where different team members are using different development tools; some use emacs, some netbeans, I use eclipse. Hence when this project is checked into the version control, it's just a bunch of java files and ant build files.
Every time there is a new branch or so, I checkout the project in my eclipse through subclipse plugin and generate some dependent jars, put them in classpath, then set up the source folder etc etc. This is becoming very tedious as I help out others with same configuration if they're using eclipse. Is there a way I could have some script which I can run on the project to convert and restructure it to an eclipse project?
You could have the Ant build create the .project and .classpath files for you. I've done this myself with the XMLTask suite, since those files are just XML documents. Add them to the svn:ignore property so your twitchy teammates don't get upset.
There appears to be an old ant task that does this for you, but I haven't used it myself.
I am currently using eclipse for working with Java. Additionaly I use git to synchronize my project between my laptop and my desktop PC.
The problem is now the following: I added external JARs to the project (Slick-Util, LWJGL).
But the path to each library is another on each device. So everytime I start working on the other device, I have to change the path to the jar files and the javadocs.
The libraries are all stored in my eclipse workspace. So the libraries and the projects are all in the same folder. And this folder is also commited with git.
Is there a way to change the eclipse settings (or do something else) so I do not have to change the path to the libraries and javadocs everytime?
I already googled and searched for it, but I could not find something about it.
Just don't add the libraries' jars to git. There are multiple build tools for java, which manage dependencies for you - you just state the libraries you're going to use, and the build tool downloads it for you at build time.
I would recommend Gradle, but Maven is also a very popular choice.
In gradle, you would create a file build.gradle, and define your dependencies in it:
apply plugin: 'eclipse'
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'org.lwjgl.lwjgl:lwjgl:2.9.0'
compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.0'
}
Then you would run gradle eclipse from the command line - that would add the libraries you use to the classpath in eclipse. And when you want to compile and package your project you would run gradle build from the command line. You should read about it if you're going to use it, what I describe may not be exactly what you need.
Also, there are instructions for using LWJGL with maven.
add jar files to a lib folder inside your project like this : D:\Workspace\myproject\lib\your-jar-file.jar
then go to your projects build path select libraries tab and click on add jars and NOT add external jars this way your jar files path will be relative to your project
EDIT :
I highly recommend to use a build tool as Kiril Raychev described.
it will look a bit confusing to start with but after a while and after a normal growth in your application that will lead to using different frameworks, controlling and managing dependencies and their conflicts without a build tool will literally kill you.
You can simply use -f flag on add command.
git add -f test.jar
And, then commit and push to your repo.
Up until now i usually use svn so i'm not entirely sure how it works out in git, but have you tried to store the JARs in the lib folder of the project they are used in? (Eclipse displays the lib folder so you can easiely add them to the buildpath with a right click on the library in the package explorer.)
That way the relative location/path of the libraries to the project should stay the same. Furthermore if you plan to pack the project into a JAR later you ship the libraries inside that JAR without having to worry whether the user of that file even has them on his computer.
PS: Looks like i'm a minute too late. Dave basically said the same thing.
How can I import an IntelliJ IDEA project into Netbeans?
I know I can just use IntelliJ but I prefer Netbeans...
With this particular project I can't just copy the source directory into a Netbeans project... That doesn't work?
How may I use this IntelliJ IDEA project within Netbeans?
The nbproject is a required folder by NetBeans, where it keeps its project settings. The only necessary project build files needed are the project.xml and project.properties.
In project.xml, line 5 is changed to reflect the accurate name of the user's project. Also for IntelliJ, nbintellij.iml is the required file.
So for a IntelliJ project, if you create the nbproject folder with the required files (project.xml and project.properties), you'll be able to open the folder in NetBeans
You can use the following tool I've created to convert an IntelliJ project to NetBeans, and also convert a NetBeans project to IntelliJ. Please make sure you have python installed.
https://github.com/devanshkaloti/IDEProjectConverter-Java
Short answer: I don't believe such a tool exists.
Longer answer: You probably should not be relying on a proprietary format for your project. Depending on the project, Ant+Ivy or Maven may be a better solution.