This below image is my eclipse of my two different projects. And each black rectangle is a package in folder src of Eclipse project. As you know, there a different point: The icon of each package is different.
1) first project: package has normal icon. (like java package)
2) second project: OPPS !!! It displays a folder.
And, the problem that I want to tell is: in project 1, when I type something wrong, eclipse has notice errors. For example: I declare: Example() example = new Example();
But at project 2, Eclipse cannot. That you have seen on my screen: Eclipse eclipse = new Eclipse();
Obvious, when compiled, It failed.
I think that I might do something wrong, and I just a newcomer to Eclipse, and really don't understand much this IDE.
Please help me for my problem.
thanks so much :)
As I think, because you have imported "your package" just by move your source. there are two ways (with my knowledge) that might work:
1) Like Baldrick does.
2) go to Properties\Java Build Path\Projects: add a project that contain package you want to add. this will make two project a linker. when you compile this project, this will also compile project that you link to.
Right now the second (lower) project doesn't have the source directory set up as a source directory, so it isn't trying to compile it. No compilation, no errors. Update your project settings by right-clicking and adding the source directory to the source paths.
Right click on your projects, go to "Properties" and "Java Build Path". In the "source" tab, add your folder src to the list of source folders.
Looks like you've created a New Folder in your project AndroidGame whereas you created New Package in your other project (can't see name).
You should create a new package in your AndroidGame source folder and "Refactor->Move" your source to it.
As an Eclipse newbie question, you should always Create Package (File -> New -> Package) when creating a package. Folders tend to be required for web content, images, resources (say for property files to be added in your target classpath), etc.
Related
Related: IntelliJ does not show 'Class' when we right click and select 'New'
In the above accepted answer, it says the "New" does not give the option for Java Class because it was not the source root (blue directory).
However, as you can see, even though where I am right-clicking is source root, indicated by blue box, it is not giving me the option for Java Class
Any idea why?
This directory is imported from git so it did not follow the usual "Create Project" for java directly from Intellij
You are right clicking in the wrong spot -- youre "too high" up the tree. Go to where you code is (as in the package under "src") and try it there and you will see the option for a New Class.
EDIT: You don't need to be in the source root. You need to be in the source directories themselves. The blue dot I believe is a git status indicator. What you want is an entirely blue folder.
Go down under "src". Likely under "src" then "main" then "java", and you're there (that's blue for me) and then you will see your package folders. Below those are where you likely want to be adding classes.
As many mentioned above you can right click on the folder you would like it in. In your case:
If you push Alt+1, it might be easier for you to right click
src > New Java Class
Alternatively you can push:
Alt+1 (Project View)
Alt+Ins
or
Ctrl+Alt+Ins
1) Right click on src
2) Click New > package
3) Name your package and press OK
4) Right click the newly made package
5) New > Java Class
If the folder where we are trying to create the class is not marked as source or test then the option is not available.
Right click the project and go to project structure then under project settings -> Modules, Select the folder where you wanted to create class and mark as Source or Test appropriately and then click apply and ok.
Now you will see the change of color of the folder/package(Sources->Blue, Test->Green) and you will get the option to create the class.
This worked for me.
I know this is an old thread, but it happened to me because my gradle files were not synchronized. So if you are within a team working on same project and face this issue, make sure to run gradle sync.
You should go inside java project then you can create java class.
My eclipse seems to be pretty screwed on my laptop. Whenever I load a program up from College, it does not detect the errors or anything. Also now when I attempt to run the program, it won't allow it; i'm given the message
unable to find an ant file to run
Anyone able to help me out?
1-Create a new project in Eclipse
2-After the project is created, look in the package explorer window pane on the left and right click on the src folder.
3-There are two methods for the next step, you could either add a New > Class, and then copy and paste everything from your old java file to the new class (make sure the class name is the same), or the better route would be to Import.
4-After clicking Import, select File System under the general folder. Click Next.
5-Browse for the java folder where your source files are located. Once you click ok, it will add all of the source files to the right pane.
6-Select which files you want to add and click Finish.
7-Now if you look at your Package Explorer window you should see the source files. Now just
compile them, and the error shouldn't appear and you can run them just like before.
By creating the new project, you're making sure Eclipse knows where your source files are located (in ./src) so that it can compile your code in that location.
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.
I've got a copy of a java package, with example implementation. The package is in a structure called com.java.project (folders, containing myriads of .java files) and there's also a few example files (example1.java, example2.java)
The example files have 'import com.java.project' calls in them, that's all well and good. However, I can't seem to work out how to get Eclipse finding the package contents (currently returns "Type not found" for any calls to the project objects.
I've tried placing the com structure in the same level as my example1.java, but that doesn't work. I have read that I need to compile the package into a .jar to get it to work w/Eclipse, but that doesn't seem to want to behave, none of the files compile.
In Eclipse you can right click on the Project Explorer and select "New -> Java Project"
Then you can import your java files by right clicking your project, selecting import from file system. If the class file shows an error, open the class file, the class name should have red curly braces, click on the error tick mark and Eclipse will give you an option to move the file to the correct package which in turn creates the folder structure for you.
1.Can you do a check on the build path of your Java project? (Right-click the project -> Properties -> Java Build Path -> Source tab), and see if the root folder contains the code is properly specified here.
2.Maybe a Project->Clean will help as well.
Hii,
Just Create a new project with File -> New menu
you need to open Java Perspective and there you will find a package named "src" you need to copy your "com" directory and paste it at the src folder.
I hope this will work for you.
This question already has answers here:
How to import a Java project to Eclipse?
(7 answers)
Closed 5 years ago.
Comment on Duplicate Reference: Why would this be marked duplicate when it was asked years prior to the question referenced as a duplicate? I also believe the question, detail, and response is much better than the referenced question.
I've been a C++ programmer for quite a while but I'm new to Java and new to Eclipse. I want to use the touch graph "Graph Layout" code to visualize some data I'm working with.
This code is organized like this:
./com
./com/touchgraph
./com/touchgraph/graphlayout
./com/touchgraph/graphlayout/Edge.java
./com/touchgraph/graphlayout/GLPanel.java
./com/touchgraph/graphlayout/graphelements
./com/touchgraph/graphlayout/graphelements/GESUtils.java
./com/touchgraph/graphlayout/graphelements/GraphEltSet.java
./com/touchgraph/graphlayout/graphelements/ImmutableGraphEltSet.java
./com/touchgraph/graphlayout/graphelements/Locality.java
./com/touchgraph/graphlayout/graphelements/TGForEachEdge.java
./com/touchgraph/graphlayout/graphelements/TGForEachNode.java
./com/touchgraph/graphlayout/graphelements/TGForEachNodePair.java
./com/touchgraph/graphlayout/graphelements/TGNodeQueue.java
./com/touchgraph/graphlayout/graphelements/VisibleLocality.java
./com/touchgraph/graphlayout/GraphLayoutApplet.java
./com/touchgraph/graphlayout/GraphListener.java
./com/touchgraph/graphlayout/interaction
./com/touchgraph/graphlayout/interaction/DragAddUI.java
./com/touchgraph/graphlayout/interaction/DragMultiselectUI.java
./com/touchgraph/graphlayout/interaction/DragNodeUI.java
./com/touchgraph/graphlayout/interaction/GLEditUI.java
./com/touchgraph/graphlayout/interaction/GLNavigateUI.java
./com/touchgraph/graphlayout/interaction/HVRotateDragUI.java
./com/touchgraph/graphlayout/interaction/HVScroll.java
./com/touchgraph/graphlayout/interaction/HyperScroll.java
./com/touchgraph/graphlayout/interaction/LocalityScroll.java
./com/touchgraph/graphlayout/interaction/RotateScroll.java
./com/touchgraph/graphlayout/interaction/TGAbstractClickUI.java
./com/touchgraph/graphlayout/interaction/TGAbstractDragUI.java
./com/touchgraph/graphlayout/interaction/TGAbstractMouseMotionUI.java
./com/touchgraph/graphlayout/interaction/TGAbstractMousePausedUI.java
./com/touchgraph/graphlayout/interaction/TGSelfDeactivatingUI.java
./com/touchgraph/graphlayout/interaction/TGUIManager.java
./com/touchgraph/graphlayout/interaction/TGUserInterface.java
./com/touchgraph/graphlayout/interaction/ZoomScroll.java
./com/touchgraph/graphlayout/LocalityUtils.java
./com/touchgraph/graphlayout/Node.java
./com/touchgraph/graphlayout/TGAbstractLens.java
./com/touchgraph/graphlayout/TGException.java
./com/touchgraph/graphlayout/TGLayout.java
./com/touchgraph/graphlayout/TGLensSet.java
./com/touchgraph/graphlayout/TGPaintListener.java
./com/touchgraph/graphlayout/TGPanel.java
./com/touchgraph/graphlayout/TGPoint2D.java
./com/touchgraph/graphlayout/TGScrollPane.java
./TG-APACHE-LICENSE.txt
./TGGL ReleaseNotes.txt
./TGGraphLayout.html
./TGGraphLayout.jar
How do I add this project in Eclipse and get it compiling and running quickly?
Create a new Java project in Eclipse. This will create a src folder (to contain your source files).
Also create a lib folder (the name isn't that important, but it follows standard conventions).
Copy the ./com/* folders into the /src folder (you can just do this using the OS, no need to do any fancy importing or anything from the Eclipse GUI).
Copy any dependencies (jar files that your project itself depends on) into /lib (note that this should NOT include the TGGL jar - thanks to commenter Mike Deck for pointing out my misinterpretation of the OPs post!)
Copy the other TGGL stuff into the root project folder (or some other folder dedicated to licenses that you need to distribute in your final app)
Back in Eclipse, select the project you created in step 1, then hit the F5 key (this refreshes Eclipse's view of the folder tree with the actual contents.
The content of the /src folder will get compiled automatically (with class files placed in the /bin file that Eclipse generated for you when you created the project). If you have dependencies (which you don't in your current project, but I'll include this here for completeness), the compile will fail initially because you are missing the dependency jar files from the project classpath.
Finally, open the /lib folder in Eclipse, right click on each required jar file and choose Build Path->Add to build path.
That will add that particular jar to the classpath for the project. Eclipse will detect the change and automatically compile the classes that failed earlier, and you should now have an Eclipse project with your app in it.
I think you'll have to import the project via the file->import wizard:
http://www.coderanch.com/t/419556/vc/Open-existing-project-Eclipse
It's not the last step, but it will start you on your way.
I also feel your pain - there is really no excuse for making it so difficult to do a simple thing like opening an existing project. I truly hope that the Eclipse designers focus on making the IDE simpler to use (tho I applaud their efforts at trying different approaches - but please, Eclipse designers, if you are listening, never complicate something simple).
This assumes Eclipse and an appropriate JDK are installed on your system
Open Eclipse and create a new Workspace by specifying an empty directory.
Make sure you're in the Java perspective by selecting Window -> Open Perspective ..., select Other... and then Java
Right click anywhere in the Package Explorer pane and select New -> Java Project
In the dialog that opens give the project a name and then click the option that says "Crate project from existing sources."
In the text box below the option you selected in Step 4 point to the root directory where you checked out the project. This should be the directory that contains "com"
Click Finish. For this particular project you don't need to do any additional setup for your classpath since it only depends on classes that are part of the Java SE API.
In the menu go to :
- File
- Import
- as the filter select 'Existing Projects into Workspace'
- click next
- browse to the project directory at 'select root directory'
- click on 'finish'