Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Install and Setup JavaSDK and Cucumber (MacOS): Difference between revisions

From KKM-STUDIO-WIKI
 
(35 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''READ ME FIRST'''
'''READ ME FIRST'''
*This tutorial applies to the '''MAC''' operating system, you can also check '''[https://kkmstudio.familyds.com/mediawiki/index.php?title=Install_and_Setup_JavaSDK_and_Cucumber_(WINDOWS) WINDOWS]''' tutorial.<br>
*This tutorial applies to the '''Mac''' operating system, you can also check '''[https://kkmstudio.dk/mediawiki/index.php?title=Install_and_Setup_JavaSDK_and_Cucumber_(Windows) Windows]''' tutorial.<br>
*This tutorial is based on this file (Programming Exercises Course 02161 Week 1 written by Hubert Baumeister in January 2022) to make additions and changes.
*This tutorial is based on this file (Programming Exercises Course 02161 Week 1 written by Hubert Baumeister in January 2022) to make additions and changes.
*Contact Shuokai Ma ([mailto:s214919@student.dtu.dk s214919@student.dtu.dk]) if you find a problem or have suggestions for this Wiki.
*Contact Shuokai Ma ([mailto:s214919@student.dtu.dk s214919@student.dtu.dk]) if you find a problem or have suggestions for this Wiki.
= Install Homebrew =
= Install and Verify JavaSDK =


Go to the [https://brew.sh/ Homebrew Installation Page]. Copy the following code to your terminal:
== Download JavaSDK ==


<code class="mwt-code">/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"</code>
Go to the [https://www.oracle.com/java/technologies/downloads/ JavaSDK Download Page]. Based on your OS, download the following file (Java 21 recommended):


The terminal will ask you to provide your password. Enter your password and then press the RETURN/ENTER to continue.[[File:Mac01.png|400px|center|thumb|Homebrew Installation]]<p>Once the installation is done, you can check if you have installed the Homebrew successfully by writing <code class="mwt-code">brew --version</code>in the terminal. It should show the following message:</p>
macOS: ARM64 DMG Installer (for M series chips) or x64 DMG Installer (for Intel chips)


[[File:Mac02.png|400px|center|thumb|Verify Homebrew]]
== Install JavaSDK ==


= Download and Install JavaSDK =
'''Double-click''' the file you downloaded and then '''double-click''' the '''pkg''' file, you should see the following interface[[File:Mac install java.png|400px|center|thumb|Java(TM) Installing Program]]
== Install and Verify JavaSDK ==
Open your terminal and write the following code: <code class="mwt-code" >brew install java</code>. The Homebrew should then do all things for you.&nbsp;<p>Then check your installation by running <code class="mwt-code" >java -version</code></p>[[File:Mac03.png|400px|center|thumb|Install and Verify JavaSDK]]


== Verify JavaSDK (Optional) ==
Click '''CONTINUE''', and '''choose''' where you want to install it. Then you should '''provide''' your password and wait for it to finish installing and click '''CLOSE'''.&nbsp;
You should now find your JavaSDK installation directory e.g. <code class="mwt-code">C:\Program Files\Java\jdk-21\bin</code> and copy that path.[[File:10.png|800px|center|thumb|JavaSDK Installation directory]]
== Verify JavaSDK ==


Now you should modify environment variables on Windows.
Open your terminal and write <code class="mwt-code">java --version</code>. You should see the following content:[[File:Mac java.png|400px|center|thumb|Verify JavaSDK]]
#On the Windows taskbar, '''right-click''' the '''Windows''' '''icon''' and select '''System'''.
#In the '''Settings''' window, under '''Related links''', click '''Advanced system settings'''.
#On the '''<span class="uicontrol bold">Advanced</span>&nbsp;'''tab, click '''<span class="bold">Environment Variables</span>'''.
#Choose '''Path''' under the '''system variables''' and then Click '''<span class="bold">Edit</span>&nbsp;'''to modify that environment variable.
#Click '''New''' and '''Paste''' that address (e.g. <code class="mwt-code">C:\Program Files\Java\jdk-21\bin</code>) on the textbox
#'''Move up''' that textbox to the '''top''' of the list.
#Click '''OK''' and then '''Apply''' to have the change take effect.
 
[[File:11.png|500px|center|thumb|Environment Variables Dialog in Windows]]
 
You can now verify your JavaSDK using the terminal command <code class="mwt-code">java --version</code>. You should see the following content:[[File:02.png|1000px|center|thumb|Verify JavaSDK]]


= Download and Install IDE (Eclipse or IntelliJ) =
= Download and Install IDE (Eclipse or IntelliJ) =
The course will use Eclipse in its teaching material but all the things we do in the course can be done in IntelliJ too. You can download the latest version of [https://www.eclipse.org/downloads/ Eclipse] and [https://www.jetbrains.com/idea/download/#section=windows IntelliJ (Community Edition)] here. After that, you can follow the instructions of the installation wizard to install the IDE.
The course will use Eclipse in its teaching material but all the things we do in the course can be done in IntelliJ too. You can download the latest version of [https://www.eclipse.org/downloads/ Eclipse] and [https://www.jetbrains.com/idea/download/?section=mac IntelliJ (Community Edition)] here. After that, you can follow the instructions of the installation wizard to install the IDE.


= Download and Install the Cucumber plugin =
= Download and Install the Cucumber plugin =
== Eclipse ==
== Eclipse ==
From the Eclipse '''marketplace''' (from '''inside the Help menu''' of Eclipse), download the "Cucumber" plugin.[[File:03.png|500px|center|thumb|Install Cucumber (Eclipse)]]
From the Eclipse '''marketplace''' (from '''inside the Help menu''' of Eclipse), download the "Cucumber" plugin.[[File:Mac04.png|500px|center|thumb|Install Cucumber (Eclipse)]]


== IntelliJ ==
== IntelliJ ==
IntelliJ already comes with a Cucumber plugin. But I recommend you also download a plugin called '''Cucumber for Java''' since it can add support for Cucumber testing tools with step definitions written. You can download that from '''File -&gt; Settings -&gt; plugins'''.&nbsp;[[File:04.png|500px|center|thumb|Install Cucumber (IntelliJ)]]
IntelliJ already comes with a Cucumber plugin. But I recommend you also download a plugin called '''Cucumber for Java''' since it can add support for Cucumber testing tools with step definitions written. You can download that from '''IntelliJ IDEA -&gt; Settings -&gt; plugins'''.&nbsp;[[File:Mac09.png|500px|center|thumb|Install Cucumber (IntelliJ)]]


== Restart your IDE ==
== Restart your IDE ==
Line 47: Line 34:


= Download and Import the project "libaray01" to your IDE =
= Download and Import the project "libaray01" to your IDE =
You can download the zip file [https://www2.imm.dtu.dk/courses/02161/2021/files/library01.zip library01.zip] here. And then you should unpack the zip file first.
You can download the zip file [https://www2.imm.dtu.dk/courses/02161/2021/files/library01.zip library01.zip] here. And then you should '''unpack the zip file first'''.
== Eclipse ==
== Eclipse ==
You can now import the project into Eclipse by clicking '''File -&gt; Import -&gt; General -&gt; Projects from Folder or Archive'''. And then you click the '''Directory''' and '''choose''' the file you unpacked from the zip file. Then you '''mark''' that project library01 and click '''Finish'''.[[File:05.png|500px|center|thumb|Import project (Eclipse)]]
You can now import the project into Eclipse by clicking '''File -&gt; Import -&gt; Maven -&gt; Existing Maven Projects.&nbsp; '''After clicking '''Next''', proceed to click '''Browse&nbsp;'''and '''select''' the file you unpacked from the zip file. Then, '''mark '''the project '''pom.xml''' and click '''Finish'''.[[File:Mac05.png|500px|center|thumb|Import project (Eclipse)]]


== IntelliJ ==
== IntelliJ ==
You can now import the project into IntelliJ by clicking '''Open''' and '''Choosing''' the file '''pom.xml''' you unpacked from the zip file. Then '''click''' '''OK''' and '''Open as Project'''.[[File:12.png|500px|center|thumb|Import project (IntelliJ)]]
You can now import the project into IntelliJ by clicking '''Open''' and '''Choosing''' the file '''pom.xml''' you unpacked from the zip file. Then '''click Open''' and '''Open as Project'''.[[File:Mac08.png|500px|center|thumb|Import project (IntelliJ)]]


= Run the project in your IDE =
= Run the project in your IDE =
== Eclipse ==
== Eclipse ==
Find the file '''AcceptanceTest.java''' under the <code class="mwt-code">src/test/java/dtu.library.acceptance_tests</code> and then '''right-click -&gt; Run as -&gt; JUnit Test'''. You will see the following content:[[File:08.png|700px|center|thumb|Run the project in Eclipse]]
Find the file '''AcceptanceTest.java''' under the <code class="mwt-code">src/test/java/dtu.library.acceptance_tests</code> and then '''right-click -&gt; Run as -&gt; JUnit Test'''. You will see the following content:[[File:Mac06.png|500px|center|thumb|Run the project in Eclipse]]


Although the program fails the test (as it should), it proves that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:[[File:15.png|500px|center|thumb|Successfully passed the first scenario test in Eclipse]]
Although the program fails the test (as it should), it proves that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:[[File:Mac07.png|500px|center|thumb|Successfully passed the first scenario test in Eclipse]]


== IntelliJ ==
== IntelliJ ==
Find the file '''AcceptanceTest.java''' under the <code class="mwt-code">src/test/java/dtu.library/acceptance_tests</code> and then '''right-click -&gt; Run 'AcceptanceTest''''. You will see the following content:[[File:09.png|700px|center|thumb|Run the project in IntelliJ]] Although IntelliJ shows "build failed" at first, you can assume that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:[[File:14.png|700px|center|thumb|Successfully passed the first scenario test in IntelliJ]]
Find the file '''AcceptanceTest.java''' under the <code class="mwt-code">src/test/java/dtu.library/acceptance_tests</code> and then '''right-click -&gt; Run 'AcceptanceTest''''. You will see the following content:[[File:Mac10.png|500px|center|thumb|Run the project in IntelliJ]]
 
Although IntelliJ shows "build failed" at first, you can assume that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:[[File:Mac11.png|500px|center|thumb|Successfully passed the first scenario test in IntelliJ]]


[[Category:Course 02161 Software Engineering 1|1]]
[[Category:Course 02161 Software Engineering 1|1]]

Latest revision as of 02:05, 29 January 2024

READ ME FIRST

  • This tutorial applies to the Mac operating system, you can also check Windows tutorial.
  • This tutorial is based on this file (Programming Exercises Course 02161 Week 1 written by Hubert Baumeister in January 2022) to make additions and changes.
  • Contact Shuokai Ma (s214919@student.dtu.dk) if you find a problem or have suggestions for this Wiki.

Install and Verify JavaSDK

Download JavaSDK

Go to the JavaSDK Download Page. Based on your OS, download the following file (Java 21 recommended):

macOS: ARM64 DMG Installer (for M series chips) or x64 DMG Installer (for Intel chips)

Install JavaSDK

Double-click the file you downloaded and then double-click the pkg file, you should see the following interface

Java(TM) Installing Program

Click CONTINUE, and choose where you want to install it. Then you should provide your password and wait for it to finish installing and click CLOSE

Verify JavaSDK

Open your terminal and write java --version. You should see the following content:

Verify JavaSDK

Download and Install IDE (Eclipse or IntelliJ)

The course will use Eclipse in its teaching material but all the things we do in the course can be done in IntelliJ too. You can download the latest version of Eclipse and IntelliJ (Community Edition) here. After that, you can follow the instructions of the installation wizard to install the IDE.

Download and Install the Cucumber plugin

Eclipse

From the Eclipse marketplace (from inside the Help menu of Eclipse), download the "Cucumber" plugin.

Install Cucumber (Eclipse)

IntelliJ

IntelliJ already comes with a Cucumber plugin. But I recommend you also download a plugin called Cucumber for Java since it can add support for Cucumber testing tools with step definitions written. You can download that from IntelliJ IDEA -> Settings -> plugins

Install Cucumber (IntelliJ)

Restart your IDE

After you install the Cucumber plugin, you need to restart your IDE (Your IDE will also notify you to do that).

Download and Import the project "libaray01" to your IDE

You can download the zip file library01.zip here. And then you should unpack the zip file first.

Eclipse

You can now import the project into Eclipse by clicking File -> Import -> Maven -> Existing Maven Projects.  After clicking Next, proceed to click Browse and select the file you unpacked from the zip file. Then, mark the project pom.xml and click Finish.

Import project (Eclipse)

IntelliJ

You can now import the project into IntelliJ by clicking Open and Choosing the file pom.xml you unpacked from the zip file. Then click Open and Open as Project.

Import project (IntelliJ)

Run the project in your IDE

Eclipse

Find the file AcceptanceTest.java under the src/test/java/dtu.library.acceptance_tests and then right-click -> Run as -> JUnit Test. You will see the following content:

Run the project in Eclipse

Although the program fails the test (as it should), it proves that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:

Successfully passed the first scenario test in Eclipse

IntelliJ

Find the file AcceptanceTest.java under the src/test/java/dtu.library/acceptance_tests and then right-click -> Run 'AcceptanceTest'. You will see the following content:

Run the project in IntelliJ

Although IntelliJ shows "build failed" at first, you can assume that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:

Successfully passed the first scenario test in IntelliJ