But the drawbacks of using a simple text editor like Atom also become apparent really quickly: We have to do a lot of typing and busywork, and there are many ways that simple typos can lead to errors in our code. Atom doesn’t provide us a whole lot of support beyond syntax highlighting, which is helpful, but still allows for errors to crop up unnoticed, slowing down our development process.
Because of the above, developers of all stripes like to work in a variety of different development environments that that provide them with different levels of support. While many frontend and JS developers work solely in a text editor, many developers of higher level, complex languages such as Java use an IDE to speed up the development process.
IDE stands for Integrated Development Environment, and is a software application that helps you craft your applications more quickly. It automatically runs tools such as linters (code checkers) and other useful add ons, such as automatic imports, as well as allowing you to generate boilerplate (starter) code. For this course, you will learn to work with IntelliJ IDEA, the IDE that forms the code basis of Android Studio.
Before we get started with creating more complex apps, let’s get IntelliJ installed on our local machine. IntelliJ is already installed on your machine at Epicodus.
IntelliJ comes in two different versions - Community and Enterprise. The Community edition is free for you to use and download for as long as you like. Download the appropriate version for your machine here.
Once IntelliJ boots up, you will be prompted to create a new project. Make sure to select Gradle on the left hand side. Your Java version should be selected at the top.
On the next screen, enter in a GroupId. GroupId’s should have the following format:
ArtifactId is the name of your project when it is compiled into a jarfile (Java ARchive) which is how many Java class files are packaged up together in a single file. (Consider it analogous to a zip archive.)
Give your project an artifact id that is concise. You can utilize hyphens to separate words. Examples:
You can leave the version number as it currently is for now and hit next. On the next screen, your screen should look like this.
Click through and select finish. After a few moments your project will be displayed. Take a minute to poke around and familiarize yourself with the structure of your app. (Your main class file will go in src/main/java)
As you begin to write your code, you will see the automatic syntax highlighting (in form of a red squiggly line) that appears whenever there are syntax inconsistencies in your code. If you hover over the red squiggly line or red bar on the side, you will see information provided about which errors were picked up by the linter (code checker).
As you learned in Intro, we don't need to add every single file to our Git repository. For instance, we don't need to track the files inside of the build directory, because their contents are simply compiled from our source code (.java files). When someone clones down our project, they'll re-compile their own build files on their own machine using the source code. So, we can use a .gitignore file to exclude this content from our Git repository.
We also don't need the .gradle directory, as those are files that will also be generated by gradle. .idea files are generated by IntelliJ - these also get regenerated every time, so we do not need to track them.
In order to easily create a handy .gitignore file, locate the Terminal within IntelliJ, where you can run commands such as
$ touch .gitignore and other commands you are familiar with from command line work.
Create a .gitignore file now, and then
$ atom .gitignore to open the file in atom for easy editing.
You can use this link to easily create your .gitignore file. Note: You may need to add additional exclusions, such as:
build/ .gradle/ .idea/ gradle/ gradlew* settings.gradle
But please be sure to not exclude your build.gradle file from git tracking - it is an important file our projects require. We'll go into more detail about what the build.gradlefile does very soon.
You can also use the built in terminal to run
$ git init, add and commit changes as usual.
Once you're ready to share your project on GitHub, you may use options built directly into the IntelliJ GUI to do so if you would like. Select the VCS menu option, then Import into Version Control and Share Project on Github:
After selecting this option, you should be prompted to provide your GitHub login information:
Then, after logging in, you should be provided another popup window. Here, you can choose your GitHub repository's name and description, as well as the name of the remote URL:
Whenever you're ready, select Share to push the project to GitHub.
Do note that you may also use the Terminal in IntelliJ to use the same Git commands you've been executing in the command line to track projects for previous courses. (ie:
git remote add,
git push, etc.)
You are not required to use the IntelliJ GUI options to create, configure, and push to a GitHub repository, as described above. This is simply another option provided by IntelliJ. Choose the workflow that you are most comfortable with, and are likely to commit most frequently and reliably. (Your teacher uses the command line option only because it feels most familiar.)
While at Epicodus we will continue to use pivotal-git-scripts to give both partners credit for their commits. You can use the terminal to include and configure our .pairs file, and run commands to commit as a pair, as we've done in previous courses at Epicodus.