In Eclipse how do I copy the Java Build Path to a different workspace?
Somebody somewhere wrote that if you copy the project then you have copied the build path also. This doesn't seem to be the case.
I've tried copying the entire workspace to a new directory. Opening Eclipse and pointing it to the new directory has all the projects and source files but the build path for my project is empty. It doesn't even have the basic Java source files to build against (java.lang.Object).
Eclipse 3.3.0 (Europa)
Any ideas?
The build path is stored in a file named .classpath in the project's root directory. I don't know of any different way, and copying the directory should also copy that file, of course. How do you copy the project? What OS?
Be very careful...
The workspace itself is just metadata in eclipse that points to your project folders. If the projects are not actually in the workspace directory, you aren't actually copying them, just references to them.
This can happen if you use "Import existing projects into workspace" that are folders in the file system without the "copy into workspace" checkbox checked, or if you create a project using an existing directory.
If you copy that workspace to a different machine, the projecs won't be there.
If you want to share projects, your best bet would be to use source/version control (subversion, for example) and have everyone hook up to the same repository.
Another note on the build paths -- if you have a java project reference an external jar, the absolute path of that jar is stored in the build path. This can be bad if other people who are sharing that project have the jar in a different location on their machine. If this happens, you should look into using Classpath variables or user libraries in eclipse.
Can you comment more on what you're attempting to do when you do the copy?
Related
I have removed the .eclipse folder, .p2 and the eclipse folder from user->local. But somehow when I am running eclipse its creating a workspace folder at the predefined location which I defined during first use. Do I also have to remove the gradle folder or How can I remove it completely it's so annoying.
Create one fresh work space, then open the workspce in eclipse it will create the new workspace configuration.
Due to the fact that you can start Eclipse even after deleting the .p2 folder, I conclude that you installed Eclipse as a ZIP package and not via the Eclipse Installer.
The predefined location of the workspace is stored inside the configuration area which is by default the subdirectory configuration of the Eclipse installation directory.
The Eclipse Java IDE uses in addition to the directories already mentioned by you, for Maven the .m2 and for Git the git subdirectories of the user directory by default. Additionally installed plug-ins might have used further directories.
I want to make it so, that when I export my project, Eclipse would create .jar file as well as folders and other files I desire on the same path. I am making a game and I rely a lot on external files, be it animation images or scripts, and it is very annoying copy pasting same stuff over and over again, additionally to making the "run" option not viable.
You can use Eclipse File sync Plugin to solve your problem, basically
this plugin synchronizes your eclipse workspace files to any external
folder you configured:
FileSync plugin for Eclipse is a file synchronisation tool. The main
goal is to keep files outside of Eclipse projects in-sync with Eclipse
project files. The plugin works as builder in Eclipse and will
synchronize all changes on Eclipse project files with mapped external
folders. E.g. if a file is created, changed or deleted in Eclipse,
then the mapped (external) file will be created, changed or deleted
too.
http://marketplace.eclipse.org/content/filesync
I have a java project made with Eclipse.
While working on a project, Eclipse creates a bunch of files and folders, what folder and files should I upload on GitHub?
I think that everything under the src folder should be uploaded. Am I right? Should I commit the .java or the .class files?
source control such as git are used to commit anything that can be called as source and not environment specific. So code, related resources should go but any IDE specific files.
Use gitignore either project specific or globally. The easiest way is to create a .gitignore file in your project root repository. For instance
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
out/
artifacts/
# Mac
.DS_Store
# Maven
log/
target/
It depends on which files do you want to share too.
For example, in my current company almost all my colleagues and I use Eclipse, so we have repositoried .project" and .classpath too. It is very handy because changes in .classpath are done only once, and then propagated to all developers.
If your root folder is both the git repo root and your workspace, you won't probably want to upload the .metadata folder, since it contains settings specific to each different developer. And, by all means, you will want to ignore Eclipse's compiled directory (typically /bin).
Think about what do you want to share and/or version, and that will probably give you a list of things to upload/ignore.
Edit: as said before, upload ONLY .java files, .class files are products of your source code, and have to be generated, not stored.
I have two projects in NetBeans that are dependent upon each other, and one references the JAR of the other one. Currently it copies all the JARs it is dependent upon into the dist/lib directory, but I don't want it to copy them--I want it to directly reference the other project's JAR from that dist directory.
How do I do this through NetBeans without manually editing the classpath?
You might want to look into using Maven for your projects. It's a tool that gives you more control over the build process and clarifies your projects' dependencies. The latest versions of Netbeans come bundled with Maven support.
I actually think that this is not possible. The "connection" between projects is for within Netbeans only, while the dist folder is, as its abbreviation suggests, for distribution.
That means that you should be able to simply copy the contents of the dist folder anywhere else, even other machines, and it should work as is (provided there is Java installed, and other such "tiny" dependencies).
If the main JAR in your dist folder would just reference the other dist folder you would not be able to run in on some other machine, unless you would copy the other dist folder in the exact location, etc. which is simply not a good thing to do or to have to do.
So, either go with Maven as MrDrews suggested or accept the libs in dist as a must.
I am now doing a project using Eclipse, and I have some resource files (e.g., image, text) saved in the bin folder, and these files are needed by the program.
However, with every build, Eclipse would try to clean up the folder, then rebuild the project. When cleaning, it deletes the resource files in the folder. Is there anyway to stop Eclipse from doing this?
I know I could change the location of the files, but I am also curious why Eclipse would do this, and could this be prevented from happening.
Thanks!
Go to Options -> Java-> Compiler -> Building and uncheck Scrub output folders when cleaning projects.
That did the trick for me. In my project, I have an Ant task that adds a few configuration resources to the bin folder to include them in the classpath, without having them in src
I can't say exactly why it does it, but probably that's just how Eclipse does the build: empty the "output folder" and start compiling.
That said, if you put your files into a source folder, then Eclipse will simply copy the files over to bin on every build and they won't disappear. It will do this to any file it doesn't know how to compile, e.g. .xml, .xsd, .png, etc.
You can consider using a maven style project and add the resources to the resources folder.
Here is a link to maven directory layout.
What kind of project you are using in eclipse. You can turn off build automatically feature in the Project menu. Which would stop eclipse from cleaning up projects automatically.
Copy and paste your resources into the source folder. In eclipse, in package explorer, find your project, then paste into src. It then gives an option to copy the file or link to it. Click copy and it gets stored in /bin but won't get deleted.