I installed Eclipse, an integrated development environment for the first time, and even output "Hello world!" I pushed the code to github.
I will keep it as a memorandum when using Eclipse in the future.
Create a remote repository on github
Press the "+ (plus)" button at the top right of the github screen and select ** New Repository **
Enter the name of the repository in ** Repository name ** and press ** Create repository **
Create a "new Java project"
Select [File] → [New] → [Other] from the menu. When the wizard appears, select [Java Project] and click Next.
Select "Yes" when the "Open the associated perspective?" Window appears.
The "New Java Project" window will be displayed. Enter an arbitrary project name in the [Project Name] field and click the "Finish" button.
Create a "new Java class"
After creating a new project, the "Java Perspective" will be displayed. (If the "Welcome" screen is still displayed, close it)
From the Eclipse menu, select [File] → [New] → [Class] to display the "New Java Class" window.
Enter "Class Name" in the name. In Java, it is customary to capitalize the first letter of the class name, so give the class name an easy-to-understand alphanumeric character. Check ** public static void mail (String [] args) ** and ** Generate comment ** and click the "Finish" button.
Java program description-Hello World! ~
Add one line of "System.out.println (" Hello World! ");" Under (// TODO automatically generated method stub).
After writing the source code, select [File] → [Save] from the Eclipse menu to save the code.
Executing Java program
To run the Java program, click the green "Run" icon under the Eclipse menu. (Alternatively, select [Run] → [Run] from the menu, or press the shortcut key [Ctrl + F11])
When the program completes without error, "Hello World!" Is displayed in the "Console View" below.
Create a Git repository (git init)
Click the "Open Perspective" icon in Eclipse, or click [Window (W)]-> [Open Perspective (R)]-> [Perspective (O)]-> [Other (O)] in the Eclipse menu.
Select "Git" from the "Open Perspective" window and press the "Finish" button.
Creating (initializing) a new local Git repository
Open the Git Perspective and click Create New Local Git Repository.
Specify any folder in "Create new Git repository"-"Repository directory" and click the "Finish" button.
Track Git repositories (git add)
After creating a new repository, share the managed Java project with the Git repository. Click the Java Perspective icon to return to the Java project perspective you just created.
Right-click in the "Java Package Explorer" view → select [Team] → [Share Project] from the menu.
In the repository field of the "Configure Git repository" window, select the Git repository you created earlier and click the "Finish" button.
Select the file to be tracked (the file you want to push) and click [Team] → [Add to Index] from the right-click menu. Keep track of file changes by adding Java files to the index.
Commit the Git repository (git commit)
The tracked file is recorded as a repository change history by "committing". In Package Explorer, select the file whose change history you want to manage and select "Team"-> "Commit" from the right-click menu.
The Git Staging View is displayed, and the file you just added to the index is listed in the Staged Changes box. "Stage" is a Git term for adding to an index.
To save (commit) the change history of the file, write a comment in the "commit message" and then click the "commit" button.
Check the commit history. Select [Team] → [Show in History] from the right-click menu of Package Explorer. You can check the "commit ID" and "message" from the history.
push
Right-click on the project linked to the repository and select "Team> Remote> Push". Select the destination repository (URL automatically generated when creating the remote repository in 1.), source reference (master), and destination reference (master), and complete. This completes the push to the remote repository.
From installing Eclipse to how to use it-Let's run a Java program in Eclipse! Using Git in Eclipse (4) Summarize the flow up to push.
Recommended Posts