External output folder in eclipse - eclipse

Is there a way in eclipse to make the project's output folder an external folder, instead of a folder located under the project root?

Yes, you can define it as a linked folder.
This this SO answer for more (or this one)
To create a new linked folder select New->Folder, input bin in the folder name: field then click Advanced>>
Click Link to folder in the file system
Click on Variables... to bring up the Select Path Variable dialog.
If this is your first time, or you are linking to a new location select New... and give the variable a sensible name and path.
More precisely, you define your output directory (say 'bin') as a linked folder, then you set that directory as the official output one of your project.

Related

Project Explorer - Project name different from actual folder name

I have a folder "JDataCollectionDemo" and I change some variables example int temp from 40 to 50, and now I want to rename this folder as "JDataCollectionDemo50". When I open JDataCollectionDemo50 as a projectfrom File Systems, it will always shows up as "JDataCollectionDemo" under the project explorer.
How can I open it as a "JDataCollectionDemo50" folder under the project explorer? I might "JDataCollectionDemo100" but I always get one "JDataCollectionDemo" folder instead.
The name you see in eclipse isn't the folder name. It is the name which is stored in the .project file (which depending on how you import the project may be the folder name initially).
You can either
remove the project from eclipse rename the folder and the name in the .project file and then re-import the folder
or, easier
select the project in eclipse and press F2 to rename it

How to place a file on classpath in Eclipse?

As this documentation says, "For example if you place this jndi.properties file on your classpath", but how can I place the .properties file on my classpath if I am using Eclipse?
Just to add. If you right-click on an eclipse project and select Properties, select the Java Build Path link on the left. Then select the Source Tab. You'll see a list of all the java source folders. You can even add your own. By default the {project}/src folder is the classpath folder.
One option is to place your properties file in the src/ directory of your project. This will copy it to the "classes" (along with your .class files) at build time. I often do this for web projects.
This might not be the most useful answer, more of an addendum, but the above answer (from greenkode) confused me for all of 10 seconds.
"Add Folder" only lets you see folders that are the sub-folders of the project whose build path you are looking at.
The "Link Source" button in the above image would be called "Add External Folder" in an ideal world.
I had to make a properties file that is to be shared between multiple projects, and by keeping the properties file in an external folder, I am able to have only one, instead of having a copy in each project.
Well one of the option is to goto your workspace, your project folder, then bin copy and paste the log4j properites file.
it would be better to paste the file also in source folder.
Now you may want to know from where to get this file, download smslib, then extract it, then smslib->misc->log4j sample configuration -> log4j here you go.
This what helped,me so just wanted to know.
Copy the file into your src folder. Go to the Project Explorer in Eclipse, Right-click on your project, and click on "Refresh". The file should appear on the Project Explorer pane as well.

Viewing a modified file in eclipse

I was adding a simple file to one of my programs that updates when I run the program with a particular parameter.
The file updated fine, but it is stored in the /bin directory and I can't figure out how to view the file within the editor.
I can see that the file is updated when I traverse the bin folder manually and open it with notepad.
Is there a way to view the file within the editor?
edit: I have a file in the project already but I doesn't update, instead the copy in the bin folder does; Can I connect the two somehow?
Your <project>/bin directory is being filtered from view. Right click on your project, select Show In->Navigator then you should be able to see your /bin directory and double click your file to have it open in an editor.
Alternatively, you can use ctrl-shift-r to open the Open Resource dialog, from the triangle drop down menu check Show Derived Resources, and then type in the name of your file.
The /bin directory is managed by the Eclipse builders and so you may lose your file if you do a clean. I would suggest using a different directory to house your runtime files.

How to rename subpackage folder name in eclipse

I am using WaveMaker and Eclipse IDE. In WaveMaker,I create java services and edit them using eclipse. Have to set its default service package's path into services/serviceName/src package folder.Right clicking on src folder and select 'Use as Source Folder' option open another window.
Now the problem is:
my folder name is now : services/serviceName/src/com/subpackage1/subpackage2/subpackage3/subpackage4/subpackage5
I want to rename it as services/serviceName/src with default package in which java file is there. Its not allowing me to rename it as above..
Below is the screenshot.
I want to rename it to services/userSignupService/src
I think you're slightly mistaken here.
services/serviceName/src/com/subpackage1/subpackage2 is not the name of your folder. It is just the full package path.
Your services/serviceName/src will still be there if you can go to the workspace in Windows Explorer and explore
Okay. I was giving full path name while creating java service in wavemaker. I've created it without full path. and in Eclipse, Right Click>Build Path>Use as source folder works.

How do I change a Java project's bin folder in Eclipse?

When you have a Java project in Eclipse, how do you change the location where the class files are placed? The bin directory is the default location.
You can change the folder name from bin to something else.
Right click on your project and select Properties.
And then click on Java Build Path.
On the right side you can see the tabs Source, Projects, Libraries,...
Click on Source. Check the Default output folder:. There you can browse and select the different folder you want.
But you cannot change the directory. For example if your project is in D: drive you cannot keep the output folder in C: drive.
Right click on your project and select Properties.
Java Build Path --> select the Source tab
See the below image for more details:
Right-click on our project --> select properties --> select Java Build Path --> select the Source tab. At the bottom of the tab you should see a field named (Default Output Folder:).
I would like to describe an approach below.
First, create a new empty project locally in eclipse work space for storing generated output files say output_bin.
As mentioned in above steps, now from Default Output Folder we need a new Variable to link to our project output folder.
Default Output Folder -> Browse -> Create New Folder...
-> Advance -> check "Link to folder in the file system" ->
Variables -> New.. -> Name = PROJECT_OUT, Location = "CHOOSE_PATH_TO\output_bin\bin\Project1bin" -> Ok
Note: Project1bin is a new directory which stores the bin folder. output_bin is an empty project and you can have multiple bin folder for various projects.
These answers only describe changing for one specific project.
But if you are using a build tool in Eclipse such as Gradle, you are likely to get annoyed by spurious build errors caused by class files being produced under \bin... the best thing is therefore to change the default output folder:
(Eclipse Mars)
Window --> Preferences --> Java --> Build Path --> Output folder name: change from "bin" to "build"
NB be aware, however, that this (currently) only appears to work when you create a new Java project using the Java project wizard. I import Gradle (STS) projects and find that I nevertheless have to change manually from "bin" to "build" for each project.