I have been moving my Java projects from Jdeveloper over to Eclipse whenever I have to go back and make a change (I only work with Java projects sparingly).
Everytime I try to create a project in Eclipse (3.3.2) I spend quite some time trying to figure out the proper way to configure the source directories in the Java build path dialog.
The biggest problem I'm having is getting the source directories to match up with the package specified in the source files. For Example my project looks like this:
MyProject
DevelopmentBuilds
MainSRC
The MainSRC directory is also the "Root" package so my classes would be defined as:
package MainSRC.Sub1;
If I set my included directory to blank, the files compile but with many errors because the Packages are not in the right place.
How do I tell eclipse to start at MainSRC for the compilation rather than the children of MainSRC?
Or, should I the path up with one src folder with MainSRC as subfolder?
I basically don't understand how this works.
you need to set MainSRC as a 'Source Folder'.
Apparently, you project root are set as Source Folder.
Enter in project properties:
. Right click over your Project root, and select Properties
. Choose Java Build Path
. Remove all source folders
. Click 'Add Folder'
. Select 'MainSRC'
. Click Ok and Ok
Now, your MainSRC are a Source Folder. Some error occurs inside source files. For agile process, right click over package 'Sub1', and press F2. Rename your package for a new, then all your source files will be put in the correct new package.
[]'s,
And Past
You would need to set the source directory to the root MyProject directory. You would have to tell Eclipse to exclude the other directories (such as DevelopmentBuilds) as they are not source code.
You might find you're better off conforming to Eclipse's expectations and creating a source folder which contains your main package folder.
Related
This may be a dumb question, but I am having trouble creating a haskell module in eclipsefp. I can open the HaskellModule wizard but if I click browse next to source folder there is nothing except my project. My project has folders on it but they do not appear on the dropdown.
You need to define what source folders are in the Cabal file for your project. By default this may be the root folder, this is why you only see your project. In the cabal file say that your source folders are some of your sub folders and you should see them available in the wizard.
Bu default a new EclipseFP project uses src as a source folder, not the root.
I hope it's OK to ask this here. Netbeans forums isn't responding. If not, I'll delete this or ask for it to be deleted. I'm desperate so I'll face the wrath, if any.
I moved my Netbeans projects folder from one directory node to another to make backing up all my stuff easier. BAD MOVE.
Now when I open a project using Files | Open project (ctrl-shift-O) NO source files appear because there is no "+Source Packages" node to expand.
It looks like this for all projects, e.g. one named GBL:
Projects
-GBL
+Libraries
It doesn't look like this anymore:
Projects
-GBL
+Source Packages (How do I get this back?)
+Libraries
The Netbeans Properties for each project shows me the path it's using. Windows 7 Explorer shows me that the src, build, and nbproject folders contain files and ALL the source files are in the src folder for that path.
What have I done and more importantly what should I do to get back to being able to open a project normally?
(I've tried recreating the original Netbeans folder and using Windows Explorer to copy an entire project folder into it but: same result--all I see is the Libraries node under the project's name node.)
I just tried to Clean (and also Build) to see what would happen. Error:
ant -f C:\\Users\\Dov\\Documents\\NetBeansProjects\\BasicShirt -Dnb.internal.action.name=build jar
C:\Users\Dov\Documents\NetBeansProjects\BasicShirt\nbproject\build-impl.xml:[u]231[/u]:
Must set src.dir
I just Set Configuration by right-clicking the project's name and provided a path to the src folder.
NOW I SEE MY SOURCE FILES BUT NOW THIS line in the .xml file is flagged with similar message:
<fail unless="[u][b]test[/b][/u].src.dir">Must set test.src.dir</fail>
NOW what do I do? (Netbeans 7.4.)
If I could get rid of the 7.4 automatic creation of +Test Packages, I might be OK.
If you can help, I'd be very happy.
(I'm considering re-installing 7.3 if available or removing and reinstalling 7.4 and try to avoid the "testing" requirement, but there goes all my many tweaks of 7.4.)
Well, after considerable frustration with the problem, I solved it, essentially.
It's here, in total. My synopsis plus how it helped me follows. In short, I had to set up a new java project based on existing sources using the New Project Wiz and simply direct Netbeans to the sources.
File > New Project
Choose Java Project with Existing Sources.
Type a (new) project name and ...
... make the Project Folder contains the path to where you want the new project to be stored. (For me, this is the folder where Netbeans has been able to find my sources.)
Click Next for the Existing Sources page of the wizard and ...
5a. ... in the Source Packages Folder pane, click Add Folder and ...
5b. ... navigate to your sources and select the source root folder.
Clicking Next goes to the Includes/Excludes pane, which I didn't need to use.
The team in which I'm working doesn't use eclipse and wants the src folder to be setup a certain way. I, on the other hand, am using eclipse. They would like the src folder to have, for example, the following structure: src/main/java/com/* However, they would like package declarations to only have com.* in them. If I go to project->properties and in the source tab remove the src folder as a source folder and then _only add the com.* folder as part of the source_ it will show com.* as a package, but I still have to add the whole path from src down in the .java files. Here's an example of what I have to do in order for eclipse to recognize the packages:
package main.java.com.parser;
And what the team wants is to have main and java just be a folder so the package declaration would just be:
package com.parser;
So although the file structure would still be src/main/java/com/parser, the package name would be as stated in the later example.
Is there a way to do this in eclipse? I've seen some people asking similar questions on here, but they seem to have no concern that the whole path must be part of the package declaration.
I would much prefer not to do this this way, but no one else is using eclipse on this project.
Thanks for any help in advance.
In the Package Explorer, right click the src folder and select Build Path > Remove from Build Path
Then find the src/main/java folder, right click java and select Build Path > Use as Source Folder
Basically this tell eclipse that java is the folder which contains the packages and source files.
P.S. This is a very normal project setup for building with Maven. If you download the m2e (Maven to Eclipse) plugins and choose to create a Maven Project (or import from the pom.xml) then Eclipse will automatically know how to correctly locate the source folder.
This may seem like a strange question but can I add a folder in the eclipse workspace that doesn't get recognized by the system? Someplace to keep my notes and java files I'm not ready to including in the build yet?
I tried putting a directory my under src but ecplise tried to compile the files in there, I just want a place where I can keep stuff I don't want eclipse to look at
Thanks
Try excluding a folder/files by:
Right-click a project folder in Project Explorer tree and then go to
"Properties".
click on Resource and then go to "Resource Filters".
Add exclusion filters for files/folders .
I have read some questions on this around here but my tries at the answer have not yielded success. Here is the problem:
Package:com.me.a
Folder(under above package):b
Java class(under above folder):Myclass.java
The proper package structure is com.me.a.b, but eclipse thinks 'b' is a folder. When I right click on b and go to build-source, there is an option that says "use as source folder" which then does something totally unwanted - creates a separate folder with the entire package path as a source folder, and uses a default package:
Folder: com.me.a.b
Package: default package
MyClass.java
How do I solve this annoying issue?
PS: I am unable to use images which to give a better idea but being new here, there is a restriction.
You have project/com/me/a/b set as the source folder. Your build path looks something like this.
You need to set project as the source folder. Your build path will look something like this afterward.
this is very strange. packages are basically folders, so saying that you have package com.me.a with a folder in it named b is essentially the same as having package com.me.a.b.
Or there is something wrong with the Eclipse's workspace metadata for this particular project?
Try creating new project with such package and class in it see if it is any different?
The behavior you describe when choosing "b" as a source folder is expected: you are basically telling eclipse that this folder b is a source folder, a root folder for source java files. this is the default package, every sub-folder of this one is considered a different java package...
I just had this same problem with ONE folder between about 100 folders. The solution turned out to be righ click on the folder (in the package view), choose "Build Path", and then "Include" (Instead of 'use as a source foldre' as the OP did). After that the folder turned into a package.