Java Development
java -version
→ see if java runtime (JRE) already installedjavac -version
&rarr` see if java development kit (JDK) already installed
Install JDK
apt search openjdk
→ see which OpenJDK versions/options are availableheadless
is a subset of the other builds that does not include GUI (graphical user interface) support- choose
headless
to serve java to browser, other apps, or to run strictly on command line - choose package without the word headless if you want to develop stand alone java apps
- choose package with
-jdk
for developers kit (JDK)
sudo apt install openjdk-17-jdk
→ install the full OpenJDK version 17
Multiple Versions
- To manage the active version, don't forget about the update-alternatives command:
sudo update-alternatives --config java
sudo update-alternatives --config javac
- ask Ubuntu, What exactly does
update-alternatives
do? → all answers are helpful
Install Maven
mvn -version
→ see if maven already installed- Can install maven either:
- from the Apache Maven Download Page, or
sudo apt-get -y install maven
→ install via APT
- The default Maven installation directories are:
/usr/share/maven
/etc/maven
- Configure the environment:
sudo nano /etc/profile.d/maven.sh
→ eidt the config file (sample below)sudo chmod +x /etc/profile.d/maven.sh
→ make config executablesource /etc/profile.d/maven.sh
→ refresh and execute the config
export JAVA_HOME=/usr/lib/jvm/default-java
export M3_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M3_HOME}/bin:${PATH}
IntelliJ IDEA
Project Organization
There isn't a strict convention for the root folder where IntelliJ IDEA Java projects should be created on Ubuntu or any other operating system. However, there are common practices that many developers follow for organizing their projects. Here are a few of the most typical root folder locations:
1. Home Directory (User Directory)
A common location for storing all personal development projects is directly in your home directory (~/), often under a subfolder like ~/projects or ~/dev.
- Example:
~/projects/my-java-project
This keeps all your development work organized under a single folder within your home directory.
Source Control
To create a repository for a specific GitHub organization from IntelliJ IDEA, you need to follow a few steps. Here's how you can tell IntelliJ IDEA to create a repository in a specific GitHub organization:
Steps to Create a Repository in a Specific GitHub Organization:
Connect GitHub to IntelliJ IDEA: First, make sure that your GitHub account is properly connected to IntelliJ IDEA:
- Go to
File
>Settings
>Version Control
>GitHub
. - Log in to your GitHub account by clicking
Add Account
and following the authentication process (via OAuth or token).
- Go to
Check GitHub Organizations: Once you’ve connected IntelliJ IDEA to GitHub, you need to ensure that your GitHub account can access your organizations.
- If you’re part of multiple organizations, IntelliJ IDEA should show a list of all repositories associated with your GitHub account, including the ones belonging to organizations you are a member of.
Create a New Git Repository in IntelliJ IDEA:
- Open the project you want to push to GitHub in IntelliJ IDEA.
- If your project is not yet initialized with Git, go to
VCS
>Enable Version Control Integration
, and chooseGit
.
Push to GitHub:
- After enabling Git, you can push your project to GitHub.
- Go to
VCS
>Git
>Push
(orGit
>Commit and Push
).
Select the GitHub Organization:
- In the dialog that opens, IntelliJ IDEA will ask where you want to push the repository. Click on the
GitHub
button, and if you’re not already logged in, it will prompt you to authenticate. - After authentication, IntelliJ IDEA will show you a list of all your available repositories and organizations. From here, you can choose Create a new repository.
- In the dialog that opens, IntelliJ IDEA will ask where you want to push the repository. Click on the
Choose the Organization:
- When you choose to create a new repository, IntelliJ will ask you to enter the repository name and select the owner (which can be your personal account or any of the organizations you’re a member of).
- From the
Owner
dropdown, select the GitHub organization where you want to create the repository. If you're part of multiple organizations, they will be listed here. - If you're not seeing your organization in the list, make sure your GitHub token or OAuth scope grants you access to repositories in that organization.
Set Repository Visibility:
- Choose whether the repository will be
Public
orPrivate
.
- Choose whether the repository will be
Push the Code:
- Once you have selected the organization, set the repository visibility, and named the repository, click
Create
and thenPush
. IntelliJ IDEA will create the repository in the selected organization and push your local project to GitHub.
- Once you have selected the organization, set the repository visibility, and named the repository, click
Summary of Key Steps:
- Ensure your GitHub account is connected to IntelliJ IDEA.
- Create or open a project in IntelliJ IDEA.
- Enable version control and commit your project.
- Push the project to GitHub, and when creating the new repository, select the organization from the
Owner
dropdown.
By following these steps, you can easily create and push a new repository for your IntelliJ IDEA project into a specific GitHub organization.