One of the skills you can exercise to succeed within a company is being an organized person. Being able to maintain good organization of your project progress, where you store your files, your schedule, and so on can make you a more productive professional and thus more valued by the market.
When we talk about software development companies or professionals in the systems field as a whole (including professionals who work on integrating enterprise management systems, manage databases for all sorts of companies, etc.), this organizational skill should also be applied to the directory structures of your projects.
From language to language, system to system, and/or project to project, it may be necessary to make some adjustments to directories and naming conventions due to specific requirements of each of them.
In today's post, we will focus our attention on the organized creation of a Java project and the configuration of some basic elements, such as Java Libraries, for example. To do this, we will use Eclipse as our base IDE for development. After properly installing Eclipse on your machine, you can start it and follow these steps to build your project.
1 - Defining a Directory to your Workspace:
As soon as you start your Eclipse, the following screen (or a similar one depending on the version) will appear:
At this point, you should define the location on your computer where you want to store the files of your Workspace. Within a Workspace, you can work on multiple projects. In some cases, more complex configurations may need to be made due to specific project requirements, justifying a separation of projects into multiple Workspaces. Generally, I like to separate them, for example, one Workspace for the tests I perform, another for ongoing project files, and so on...
2 - Creating the Java Project:
Once you click on 'Launch', your environment will be started, and in the upper left corner of the screen that appears, you can find the 'File' option as shown in the image on the side. When you click on it, the menu will open, and you can click on 'new' or 'novo' depending on the language configuration you have set.
In the menu that opens, you can select the 'Java Project' option.
The screen below will be displayed, and you can define the name of your project and the version of Java it will use. In this case, as an example, we selected Java SE - version 15. The settings for "JRE", "Project Layout", and "Working sets" do not need to be modified initially.
After defining the name of your project and selecting the "Finish" option, depending on the basic configuration and version of your Eclipse, the following message may appear:
We recommend for basic projects that you choose not to create a module for now unless you have a good understanding of how Java modules work.
And there you have it, you now have your Workspace and your Java project created. The next step will be:
3 - Create a Package:
To avoid implementing your classes directly within your Java Project created in the previous step, we need to define a package for it so that you can place your actual code inside. One of the reasons for creating packages is to separate code related to different things. For example, in a project for a simple grocery system, we would implement inventory control codes in one package, sales-related codes in another, customer registration codes in another, and so on.
The creation of a package follows a similar process to that of creating a Project and Workspace.
Once again, in the left corner of your Package Explorer, locate the 'src' folder. This is where you will place your packages. To create a package, right-click on the 'src' folder, and then select the options shown on the side: New > Package.
After doing this, a simple screen will appear for you to define the name of the package you are creating. Inside this package, you can now place your Java classes and any necessary code.
Once you've completed these steps, your basic structure is ready for you to start working. Another configuration you may need to do is to define a library as a dependency for your project.
Configuring Library Dependency in Java Project:
Right-click on the folder of your Java Project and select 'Properties'.
The following screen will be displayed:
Click on 'Java Build Path' and then select the 'Libraries' tab. In this tab, you will add the .jar file of the library for which you want to configure the dependency. Afterward, click on 'Apply'.
Now, you can import the classes available in this library into your code (provided that it is within this Java Project).