Netbeans plugin sourcefolder - plugins

I recently started a Netbeans plugin, more a file wizard, the problem is I need to know the project source folder, for some reason I can't figure out how to get it.
I can get the project folder, but this can differ from the source folder e.g:
Project project = Templates.getProject(wizard);
project.getProjectDirectory().getPath();
Any ideas on how to get the real source folder?
Thanks in advance.

Ok I figured it out, eventually it was as straightforwarded as I expected it to be:
FileObject pkg = Templates.getTargetFolder(wizard);
and
pkg.getPath()
contains the root folder for your sources.

Related

Getting "Project folder ins managed by a project..." when opening Actviti source code in netbeans

I can't open Activiti source code in netbeans It just says "Project folder is managed by a project Activiti. Instead of creating a new project just open it. If by a chance you just deleted the project Activiti then restart the IDE to reuse the folder."
I have restarted Netbeans and re-cloned the project but it still won't open.
And eclipse just says that the javac was not found in the build.xml.
Any help would be greatly appreciated.
The project folder does not contain a nbproject folder.
Try the following:
rename the pom.xml file to something else, e.g. pom.xmlzzzz,
create the project in NetBeans,
rename pom.xmlzzzz back to pom.xml once the project has loaded in NetBeans.
I've just hit the same problem with a different project and this is what fixed it for me.
Netbeans creates a folder in your project named "nbproject". Once you delete that, restart the IDE and you're good to go.
Go to the folder containing your project
Delete the folder named nbproject
Restart Netbeans
Try creating your project again from the original folder

How to get the bin folder in eclipse

I am searching for the bin folder in eclipse, but I am not able to find it.
I tried this following post, but I am not successful. Please can anyone help me?
what can I do to make display the bin folder on eclipse?
The reason why I am looking for bin folder is, I want to place some .dll files in it. Is there another way of incorporating .dll files? Any help is appreciated
You should not put any data in the bin directory. It gets deleted if you do a Project -> Clean. Instead you should put your libraries in a lib folder. I don't know how you are actually using your dll, but you can surely point to another directory.
If you are trying to include this dll only for development purposes, you can use LD_LIBRARY_PATH and include the path for your dlls. I did this in the past with eclipse. There are a location in the CDT eclipse project where you can include this.
If you are speaking about a java aplication that needs a dll, you can add the library in the project also like this http://www.dreamincode.net/forums/topic/96304-how-to-add-dll-files-in-javalibrarypath/, but I haven't done it never.

"Sources directory is already netbeans project" error when opening a project from existing sources

I've installed NetBeans 6.9.1 and installed few updates for it.
Then I've created a new project from existing sources. After a few changes I've closed it. And now I am having an error, when trying to open a new project from existing sources (the same files):
Sources directory is already netbeans project (maybe only in memory).
After Googling it, I noticed it happened not only with me. But I didn't find the correct solution. I've tried to restart the IDE, I've tried to restart the PC, I've tried to reinstall NetBeans. Nothing helped.
Thank you!
I was having the same problem:
Sources directory is already NetBeans project (maybe only in memory).
Netbeans creates a folder in your project named "nbproject". Once you delete that, restart the IDE and you're good to go.
When you create a NetBeans project from existing sources, NetBeans uses the same directory to add its own files: a netbeans folder with .proj files.
Solution: delete the netbeans folder and restart the IDE. Opening a new project should now work.
Go to the folder containing your project
Delete the folder named nbproject
Restart Netbeans
Try creating your project again from the original folder
This means the project folder is already a netbeans project. So instead of adding it as a new project open it as
This happens(i believe) because netbeans tries to version control the files created or edited.
Under the project folder netbeans create a netbeans directory just delete it . This has been tested in Ubuntu. Then you can import your project if php then php using existing sources.
Click File >> Recent Projects > and you should be able to use edit it again. Hope it helps :)
On Windows at least none of these answers work (for me anyway!). I have found the only way is to copy an existing netbeans project folder in to your new project and manually edit the xml project name.
I also opened the private/private.xml and removed the open files xml just incase these caused problems.
Once I'd done this the project works as normal.
I checked the "Put NetBeans metadata in separate directory" tick and it works fine.
This is in 2. Name and Location after you choose PHP from existing source
In my case my project root directory consists ".project". This contain the XML reference of the project name.
By removing this, i am able to create a project.
Usually this happened when we copy source code of a already created project and copied in different folder and try to create a project from it. as netBeans create its folder nbproject in our project folder this folder also get copied with our source code and it give error "Sources directory is already NetBeans project (maybe only in memory)" remove this folder from you newly copied folder and voila you can create a new project.
If this is your own source code and you already have a Netbeans project folder with your source files you should just start with:
File | Open Project...
not
File | New Project ...
because the project is not new.
If it helps anyone else, I had the same problem and the solution was to reinstall NetBeans.
I had tried all sorts of fixes: Deleting the NetBeansProjects folders, checking/unchecking "Put Netbeans metadata in a separate directory", killing/restarting NetBeans, restarting the system, etc. Nothing cleared the message...except the reinstall.
The advice here about removing the nbproject directory is not quite the whole story.
What Netbeans seems to do (and we are guessing at reverse engineering here) is to look for an xml file which has opening and closing project tags in it. This it concludes is evidence of an already existing project. Now if your files have an nbproject directory there, that will contain a project.xml file which contains the said tags. So removing that will do what you want.
But, my files don't have a nbproject directory but still NetBeans tells me there is an existing project maybe in memory. The reason is: my files include a file called pom.xml and that contains the said project tags in the xml (it was created by an entirely different system). Once that xml file is removed, then NetBeans will create an html project for me importing my code.
In sum: look through any xml files in you existing code, and be wary of project tags.
This happened to me when I tried to import an Eclipse project in a brand new NetBeans 7.2.1 install on Ubuntu 12.04LTS.
I mistakenly selected the import projects from workspace (the first option in the import wizard's opening pane) on the first attempt, and it opened the project in the original Eclipse workspace path (which was on a usb stick).
From this, I then realized that I actually need the second option - import project ignoring project dependencies, which lets you specifically choose source and destination folders. After closing the project, I tried to import again with the proper option, but it didn't work.
From then on nothing I did helped - restart the IDE, move the source folder, nothing. There was no nbproject folder in the project or /var/cache in the user folder to delete (in-fact there was no nbproject folder in the whole file-system).
Since restart didn't work, I'm guessing that there is a garbage project entry somewhere which Nb reads (See Martin Frické answer above).
After googling along the lines of 'netbeans clear memory project cache' with no success, I opted to reinstall NetBeans -
sudo /usr/local/netbeans-7.2.1/uninstall
sudo ./netbeans-7.2.1-ml-javase-linux.sh
which solved it.
If you are on a Mac, press command shift G and in the box type /users and then go, next click on your user name and navigate to netbeansprojects and open it. Then delete the ones in there that are causing problems. You can then create your project.
Note: I had moved my wordpress folder to my desktop trying to figure this out, so I dropped it back into the origional location and it works fine. So if you did this, just replace the wordpress folder after deleting the problem projects from the netbeansprojects folder and its contents back to the original installation folder.
Hope this helps...:)
This is what I did to solve this error:
1) I copied a folder named "folder1" (and I called the new folder "folder2"). "folder1" was a Netbeans project so it had a folder called "nbproject" inside it.
2) When I tried to create a project out of the "folder2", Netbeans threw an error "Sources directory is already netbeans project (maybe only in memory)."
3) Inside Netbeans delete the project of "folder1". Then, delete the two folders named "nbproject" (one is inside "folder1" and the other is inside "folder2").
4) Inside Netbeans, create two new projects: one for "folder1" and another for "folder2". The error should not appear anymore.
copy an existing netbeans project folder in to your new project and manually edit the xml project name.
reinstall netbeans
copy/move all files/folders (except nbproject/ folder) to a new folder for your project, with a new name.
Try to create a new empty project; then you can copy the public_html to the new project folder and it will appear .
I faced the same issue:
Sources directory is already NetBeans project (maybe only in memory).
The solution is:
Netbeans creates a folder in your project named "nbproject". Once you
delete that, restart the IDE and you're good to go.

The project description file (.project) for my project is missing

I am using Eclipse PDT 3.5 on Vista (32 bit). It works, though eclipse needs admin rights to execute. This annoys me, but I accept it.
But: every now and then (I am not sure, it may even be everytime I want to open a project), I get the error message "The project description file (.project) for my project is missing.".
It is NOT missing, it is in the main folder of the project. It has no special flags set (it is not hidden, nor system file, nor write-protected).
This is for ALL projects I have in my list. The only solution I have found so far is to delete the project from eclipse an re-add it. This is somewhat annoying.
What can I do?
EDIT: The workspaces are on a server volume. Can this be the problem? I used Eclipse 3.3 before, and there it was no problem with the server paths. And the server volume is mapped to a drive letter.
I've found this solution by googling. I have just had this problem and it solved it.
My mistake was to put a project in other location out of the workspace, and share this workspace between several computers, where the paths differ. I learned that, when a project is out of workspace, its location is saved in workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/PROJECTNAME/.location
Deleting .location and reimporting the project into workspace solved the issue.
I had the same problem and in my case .project file was also present in the project directory and had correct permissions.
This problem happened to me after I closed and reopened multiple projects quickly one after another and Eclipse tried to rebuild them at the same time.
In my case Eclipse lost .location file in the workspace directory for 2 out of 5 projects: <workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects/<project name>/.location
I've followed instructions on How to get project list if delete .metadata accidentally and imported the project in the workspace manually via File :: Import :: Other :: General :: Existing Projects. After that .location file was created again and Eclipse stopped complaining.
I had the same problem, and I haven't gotten that error since I close the project before I close myEclipse and don't tidy up the default location.
My project source and compiled files are outside the default workspace but there are stubb folders created by default by myEclipse in the default workspace. When I setup the project, there are two .project files - one in the default workspace that points to the working dir, and one .project in my chosen directory.
If you move the files for whatever reason manually, then Elipse lost the reference and output a missing project file error, but the reason is thaty you move manually the files and Eclipse lost the reference
I am using Eclipse 3.5.1 on Ubuntu. After rebooting my machine my projects in PHP Explorer view were giving the warning that the .project file was missing. The problem was that the external directory where my projects are hosted was not mounted on reboot. So I did a mount -a from the command line and the Eclipse recognized the files.
If you only want to checkout and you delete the folder from the workspace you also need to delete the reference to it in the Java view. Then it should checkout as if it were checking out for the first time.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Lynxster</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
in the name tag give the name of the project folder
and save this file with .project extension
& paste it in the project folder.
this worked for me.
In my case i have changed the root folder in which the Eclipse project were stored. I have discovered tha when i have runned :
cat .plugins/org.eclip.resources/.projects/<projectname>/.location
Martin Encountered the same issue with a Minecraft Mod project when I changed the Main folder location.
Normally I would open the project like this
This is how my path looked when I started the project
I got the same "The project description file (.project) for my project is missing." Error.
I later found the .project file in the main folder like this.
This is the location where I found the .project file
I found that going eclipse to "File->Open Project from File System or Archive" and navigate to your main project folder with the .project file solved the problem.
My project is already included
This is my first post in here hoping it can help you out, Martin.
I created a new workspace and imported old projects. I just didn’t open this workspace for a long time, I don’t know why this problem happened
In my case it happened cause I accidentally removed eclipse metadata files.
So I fixed it by removing the project from eclipse, but without deleting files from disck.
And then reimport.
If you keep a backup of your worskpace folder, then all you need to do is restore the following folder from the backup:
workspace/.metadata/.plugins/org.eclipse.core.resources
It worked for me after I created and switched to a new workspace and copied my codebase there.

Editor does not contain a main type

Just going through the sample Scala code on Scala website, but encountered an annoying error when trying to run it.
Here's the code: http://www.scala-lang.org/node/45. On running it on Eclipse, I got this message 'Editor does not contain a main type' that prevents it from running.
Is there anything I need to do...i.e break that file into multiple files, or what?
In Eclipse, make sure you add your source folder in the project properties -> java build path -> source. Otherwise, the main() function may not be included in your project.
I have this problem a lot with Eclipse and Scala. It helps if you clean your workspace and rebuild your Project.
Sometimes Eclipse doesn't recognize correctly which files it has to recompile :(
Edit:
The Code runs fine in Eclipse
A simpler way is to close the project and reopen it.
You have to make sure that your .java files are in the .src folder in eclipse. I had the same exact problem until I got it figured out.
Just make sure that the folder you work in is added to the built path:
right-click your folder --> build Path --> Use as source Folder
and it should now find main therein.
You can try to run the main function from the outline side bar of eclipse.
I had the same problem. I tried all sorts of things. And I came to know that
My .java files were not linked and
they were not placed in the 'src' folder.
Things I did:
Project properties >> Java Build Path >> Source
Deleted the original 'src' folder which was empty using 'Remove' option
Added the source that contained my source .java files using the 'Add Folder' option
This solved the error.
Just close and reopen your project in Eclipse. Sometime there are linkage problems. This solved my problem
A quick solution:
First, exclude the package:
Right click on the source package >> Build Path >> Exclude
Then include it back:
Right click on the source package >> Build Path >> Include
What you should do is, create a Java Project, but make sure you put this file in the package file of that project, otherwise you'll encounter same error.
That code is valid. Have you tried to compile it by hand using scalac? Also, have you called your file "addressbook", all lowercase, like the name of the object?
Also, I found that Eclipse, for some reason, set the main class to be ".addressbook" instead of "addressbook".
you should create your file by
selecting on right side you will find your file name,
under that will find src folder their you right click select -->class option
their your file should be created
Make sure that your .java file is present either in the str package, or in some other package. If the java file with the main function is outside all packages, this error is thrown.
Have faced the similar issue, resolved this by right clicking on the main method in the outline view and run as Java application.
I just had this problem too. The solution is to make sure eclipse created the project as Java project. Just create a new Java project and copy your class into the src folder (and import the eventual dependencies). This should fix the problem.
The correct answer is: the Scala library needs to before the JRE library in the buildpath.
Go to Java Buildpath > Order and Export and move Scala library to the top
I had this problem with a Java project that I imported from the file system (under Eclipse Helios). Here's a hint: the src code didn't seem to be compiled at all, as no "bin" directory showed up.
I had to create a Java project from scratch (using the wizard), then compare the .project files of the non-working and working projects.
The project giving "Editor does not contain a main type" had this as the "buildSpec" in the .project file:
<buildSpec>
</buildSpec>
But the working project had this as the "buildSpec":
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
I copied this in, and the imported project worked.
I know my answer is for Java, but the same might be the issue for your Scala project.
May be the file you have created is outside the src(source) folder. Trying to call the class object(from the file located in the src folder) from the .java file outside the source folder results in the same error. Copy .java file to the source folder, then build it. The error will be gone.
I had the same problem. I had the main class out of the src package, in other folder. I move it in and correct folder and solved
run "eclipse -clean -refresh" from command line. This fixed the issue for me when all other solutions failed.
This could be the issue with the Java Build path.
Try below steps :
Go to project properties
Go to java Build Path
Go to Source tab and add project's src folder
This should resolve the issue.
If it is maven project please check the java file is created under src/main/java
If you are not getting please change the JRE path and create the java files in above folder structure
For me, in Eclipse 3.6, this problem occurs when my main method is not public. I caused the problem by having a main method like this:
static void main(String[] args)
The dubugger was unable to detect this by itself. I am pretty suprised Eclipse overlooked this.
In the worst case - create the project once again with all the imports from the beginning. In my case none of the other options worked. This type of error hints that there is an error in the project settings. I once managed to solve it, but once further developments were done, the error came back. Recreating everything from the beginning helped me understand and optimize some links, and now I am confident it works correctly.
Follow the below steps:
Backup all your .java files to some other location
delete entire java project
Create new java project by right click on root & click new
restore all the files to new location !!
File >> Import >> Existing Projects into Workspace >> Select Archive Filed >> Browse and locate file >> Finish. If its already imported some other way delete it and try it that way. I was having the same problem until i tried that.
One more thing to check: make sure that your source file contains the correct package declaration corresponding to the subdirectory it's in. The error mentioned by the OP can be seen when trying to run a "main type" declared in a file in a subdirectory but missing the package statement.
I have this problem too after I changed the source folder. The solution that worked for is just editing the file and save it.
Try 'Update Project'. Once I did this, The Run as Java Application option appeared.
In my particular 'Hello World' case the cause for this problem was the fact, that my main() method was inside the Scala class.
I put the main() method under the Scala object and the error disappeared.
That is because Scala object in Java terms is the entity with only static members and methods inside.
That is why Java's public static void main() in Scala must be placed under object.
(Scala class may not contain static's inside)