I've been trying to import a project that works on a friend's computer, however no matter what I try, the package hierarchy is completely lost and the result is this
Has anyone seen this issue before? I've been struggling with it for a while. Occasionally creating a new project and copying in the src folder works, but I've been unsuccesfful in my recent attempts.
The presentation of packages is a user option. Click the little down-arrow at the top of the package panel, then select "Package Presentation" from flat to hierarchical.
Turns out we weren't including the .classpath file in the source control. Facepalm. Good answers, though.
It could also be that the folders are not listed in the project as Source Folders. Go to the project properties and check that the root folders (looks like "data" and "src" here) are listed as source folders in the Build Path.
Related
Before posting this message I read tens of threads but with no success. I am trying to import a package into one of my JSP files and I keep getting the same error:
The import cannot be resolved.
I believe that something is not right with my project structure. I have tried everything, from cleanup, rebuild, even creating another project from scratch.
This is the structure of my project:
And these are the contents of my build path:
I would greatly appreciate any kind of help, this is a big blocker right now for me.
Yes, it's your project structure. Your source files are not actually under the src folder that would be listed on the Source tab of the Java Build Path property page you're showing (you can see how it's laid out that folder's contents to resemble package names). Either move the files to where they're expected or update the Source tab to point to where you're actually keeping them.
add the Java Resources/src folder to the build path or the library build path.
Thanks a lot for your answers, I have changed the project structure like in the image below and now it works:
I have been writing a project in Java that I've called NHL2 and at this point in the development I've decided to try to incorporate wheels which can be found here. I've downloaded and unzipped the folder, and tried to import the files in several different ways. In Eclipse I've tried right-clicking the NHL2 project and importing it. The files get inserted into certain places in the project but when I type import wheels.etc.* for instance, it gives me an error and says it cannot resolve the import. So I tried deleting the imported files, right-clicking the package containing my files, which is also NHL2, and running the import command through there. Again, same basic problem.
I've also tried just creating a whole separate project titled wheels and importing there. This seems to be fine and the wheels project itself has no errors, but still I cannot import those files in my NHL2 project. I've tried looking up YouTube videos and other stackoverflow questions because this seems like it's just so basic that it should have been answered by now, but I can't find it.
Create a new Folder in your Project, e.g. called "lib"
Copy the wheels.zip into that Folder
Open the properties of your Project (Alt-Enter on the Project)
Select "Java Build Path"
Select the Register Card "Libraries"
Click "Add JARs"
Select "Yourproject/lib/wheels.zip"
Click "OK" then again "OK"
Though it is no jar file (but a zip) it works. I tested it.
This is because the zip contains the class files and the source files as well.
Here's what I'm seeing:
Normally I can choose "New Java Class" but for some reason I'm not getting this option. I created this project by opening an empty directory and building it out from there. I've seen this question, but that answer didn't help me. Here's my module settings:
Even if I open my pom.xml directly as a project, it still has this problem. How do I fix this?
The directory or one of the parent directories must be marked as Source Root (In this case, it appears in blue).
If this is not the case, right click your root source directory -> Mark As -> Source Root.
For some reason, intellij didn't recognize my directories as packages. If I created something directly from the java directory, it would give me the correct options. I fixed this by deleting everything under java/ and recreating it. This may be an intellij bug.
This happened when I was trying to add classes to a generated package using xjc plugin.
Intellij allows to add classes only to packages which are correctly names and have the "source root" status.
Can be fixed as-> right click on the directory where you're not able to add classes:
Mark sources root
refer image for clarity
This worked for me :
Right click the java folder (myproject/src/main/java)
Click "Mark Directory as"
Click "Source Root"
Right click the myproject folder (myproject/src/main/java)
Click "Mark Directory as"
Click "Source Root"
So basically had to mark some inner folder as Source project and alter mark parent project again as Source project..
Hacky way but this worked for me.
The project description file (.project) for 'AutoClicker' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
I had moved computers in class and moved all my projects on a 1TB hard drive over to the new computer and I had gotten all the projects to work, but one. I have no idea how to fix it, I feel like the path to the file is wrong, but I don't see anything wrong with it.
If anyone has any idea on how to fix this error, it would be greatly appreciated.
Delete your .project file in root project and in your subprojects, then right click on project folder -> delete (not deleting it from disk).
Reimport your project, then, be happy!
Most probably you have lost the .project file during the transaction process.
Not really an elegant solution, but what you could do is create a new project in Eclipse and copy the files from your storage to the newly created project (which would have the .project file).
1) The solution for me, is to delette projet from eclipse ( important no delette content from disk).
2) Import the project
It's OK form me
I hope help U
If the .project file is in the expected location, try checking the case. On case sensitive systems (not Windows) a difference in case between the project name and the folder name may be the cause.
If you are getting this error after stash your changes with checking include untracked files then you have to follow below steps to solve the issue.
Go to your project root folder.
run git stash list. You will see your stash changes with given name.
Now apply those stash changes by running git stash apply stash#{0} where stash#{0} is having your stash changes.
Now you will be able to open your project.
Thanks.
A thing that worked with me (having tortoise) was deleting the .project file then importing it again
This question already has answers here:
Error: Selection does not contain a main type
(24 answers)
Closed 8 years ago.
I am receiving the errors: Editor does not contain main type, or, Selection does not contain main type when I import an archived Java project into Eclipse and try to run it. I have gotten this error on several different operating systems.
Archive Protocol
Export project
General->Archive File
All are selected: project folder, .classpath and .project
[x] save in zip format
[x] create directory structure for files
[x] compress contents of file
A Work Around That May Explain It... but how?!
I notice that when I import an archived project into an existing project (a blank Java project), The folder hierarchy is something like:
Project
src
bin
imported_project
bin
src
actual_code.java
Now, when I try to run actual_code.java, I get the above error. I discovered the following work around: if I drag actual_code.java and drop it into Project->src and then run it, it works.
This is a nice work around. However, I would prefer to be able to run the imported project without moving things around. Any suggestions on how to do this? It seems like it should be a trivial fix--it simply seems like the project isn't importing to where it ought to.
And yes...
I have tried every method I have come across to remedy this. That includes quite a few from this site and others: syntax, libraries, source path, restart eclipse, rearchive, different operating systems, different machines... etc.
The .java files are in the src folder before I archive them, and my build path seems correct.
You could import the archive as a Project instead of as files into a newly created blank project. Use Import > Existing Projects into Workspace. Then, use Select archive file.
You might want to put the src folder of your imported_project in classpath.
Right click on your project -> Properties -> Java Build Path -> Source -> Add Folder
I also faced the same error ajnd after reading above article i just drag/drop my class-file to src and new class-file generated in src is working fine .
I had the same problem after I New/Java Project then pulling src, docs, lib, examples, ... folders. I could not import it as an Eclipse project since the code is not an Eclipse project. The main is right there in the example code, but the IDE would find it.
The solution for me is deleting the project from the IDE, then recreating it with the Eclipse IDE. When recreating, the IDE cached all the sub-folders for me. Also, make sure you add the code onto the Java Build Path as Source using the 'Configure Build Path...' of the project.
Restarting IDE, closing then reopening the file didn't help me.