Google+

Like Us On Facebook


Total Pageviews

160. Finding the Project's Location in Eclipse IDE






Till now we have created many Java Projects in Eclipse IDE. Now lets find out the location where the projects are stored on your computer using the below 'Properties' option.

Lets create a new Java Project , find out its location using 'Properties' option and explore all the folders and files available at the location.

Lets Implement this on Eclipse IDE -

1. Launch Eclipse IDE, Create a new Java Project 'Project 010' as shown below -


2. Right Click on the Project 'Project 010' and select 'Properties' option as shown below -


3. Observe that the Project Location is displayed in the 'Properties for Project 010' dialog as shown below -


4. Go to the above displayed location on your computer and observe that the following files and folders are displayed as shown below -


5. Open the 'src' folder. We  have created this Java Project 'Project 010' without creating any Package or Class files, hence the 'src' folder is empty as shown below.



6. Now lets Create a Package 'package_010' under Java Project 'Project 010' in Eclipse IDE as shown below -



7. Now go back to the Project Location and open the 'src' folder now and observe that a folder with 'package_010' name is displayed as shown below (This got displayed as we've created a package in Eclipse IDE) -



8. Open the 'package_010' package folder. We  have created this package 'package_010' without creating any Class files under it, hence the 'package_010' folder is empty as shown below.



9. Now lets create a Class 'Class010' under 'package_010' of  'Project 010' in Eclipse IDE as shown below -



10. Now go back to the Project Location and open the 'src' folder -> 'package_010' folder, and observe that the Java Class file 'Class010' is displayed as shown below (This got displayed as we've created a Class in Eclipse IDE) -



11. Open the 'Class file 'Class010' in any text editor and observe that the default generated Java Code is displayed in the file as shown below -


12. In Eclipse IDE, write a main( ) with a statement to print "This is a sample text" text in Class 'Class010' as shown below -



13. Now go back to the Project Location and Open the 'src' folder -> 'package_010' folder -> 'Class file 'Class010' in any text editor and observe that the Java Code written in the above step is displayed in the file as shown below -


14. Now go back to the Project Location , open the 'bin' folder -> 'package_010' folder and observe that  a Class file 'Class010.class' is displayed as shown below -



Unlike other editors, Eclipse IDE automatically compiles the code on saving the .java files (i.e. No need of manually compiling before running the .java files).

On compiling, the original java code gets transformed into a low level executable code which can be understood by JVM of any environment to run it.

In Java, whenever your compile a .java source code file, the transformed low level executable code will get generated and get saved in the created .class file. In case of Eclipse IDE, it automatically compiles and creates the .class file in 'bin' folder of the project.

As the .class file can be understood by the JVM, we can run the .class file on any environment by installing JVM of the respective environment. For example, .class file got created in windows 8 environment, but you want to execute it in the Mac environment, you have to install Mac supported JVM in the MAC machine and run it and the .class file will execute there without any problems. As we can run the same Java code in different environment by just installing the JVM of that environment, we can call Java as Platform independent language. JVM makes it platform independent as it can read the .class file.

15. Now go back to the Project Location and observe that we have a .classpath file in the root folder itself as shown below -



.classpath tells Java where to look in the file system for files defining these classes.

So .classpath contains the information about where to looks for different files or folders in the project.

-> Java Compiler looks into the .classpath to find the .class and .java files of the project for recompiling the Java code.

-> While importing the Project, Eclipse looks into the .classpath to find and import the .class and .java files of the project.

-> In order to execute the Java code, JVM looks into the .classpath file to find the .class file and .java files of the project.

16. Now go back to the Project Location and observe that we have a .project file in the root folder itself as shown below -



When a Java project is created in Eclipse, .project file is automatically created. .project file describes the project. The sole purpose of this file is to make the project self-describing, so that a project that is zipped up or released to a server can be correctly recreated in another work space. Hence .classpath and .project files are required while importing the project in to a new work space.

17. Now go back to the Project Location and observe that we have a .settings folder in the root folder itself as shown below -



18. Open the '.settings' folder and observe that org.eclipse.jdt.core.prefs file is displayed as shown below -


Eclipse uses org.eclipse.jdt.core.prefs file in .settings folder of the project to store all the project specific Eclipse settings. Example - Font size of the code in .java file in Eclipse IDE is stored in the preference file of setttings folder by Eclipse IDE. .settings folder is created by Eclipse IDE on creating a Java Project to facilitate the storage of preferences.

19. Run the .java file in Eclipse IDE as shown below -



20. Observe that the output is displayed in the console as shown below -




Please comment below to feedback or ask questions.

Deleting the Java Project from Eclipse IDE will be explained in the next post. 



No comments:

Blog Index