Install and Setup JavaSDK and Cucumber (Windows): Difference between revisions
More actions
No edit summary |
|||
| (22 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
'''READ ME FIRST''' | '''READ ME FIRST''' | ||
*This tutorial | *This tutorial applies to the '''Windows '''operating system, you can also check '''[https://kkmstudio.dk/mediawiki/index.php?title=Install_and_Setup_JavaSDK_and_Cucumber_(MacOS) MacOS]''' 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. | ||
= Download and Install JavaSDK = | = Download and Install JavaSDK = | ||
== Download JavaSDK == | == Download JavaSDK == | ||
Go to the [https://www.oracle.com/java/technologies/downloads/ JavaSDK Download Page]. Based on your OS, download the following file (Java | Go to the [https://www.oracle.com/java/technologies/downloads/ JavaSDK Download Page]. Based on your OS, download the following file (Java 21 recommended): | ||
Windows: x64 Installer | Windows: x64 Installer | ||
| Line 15: | Line 15: | ||
== Verify JavaSDK (Optional) == | == Verify JavaSDK (Optional) == | ||
You should now find your JavaSDK installation directory e.g. <code class="mwt-code">C:\Program Files\Java\jdk- | 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]] | ||
Now you should modify environment variables on Windows. | Now you should modify environment variables on Windows. | ||
| Line 22: | Line 22: | ||
#On the '''<span class="uicontrol bold">Advanced</span> '''tab, click '''<span class="bold">Environment Variables</span>'''. | #On the '''<span class="uicontrol bold">Advanced</span> '''tab, click '''<span class="bold">Environment Variables</span>'''. | ||
#Choose '''Path''' under the '''system variables''' and then Click '''<span class="bold">Edit</span> '''to modify that environment variable. | #Choose '''Path''' under the '''system variables''' and then Click '''<span class="bold">Edit</span> '''to modify that environment variable. | ||
#Click '''New''' and '''Paste''' that address (e.g. <code class="mwt-code">C:\Program Files\Java\jdk- | #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. | #'''Move up''' that textbox to the '''top''' of the list. | ||
#Click '''OK''' and then '''Apply''' to have the change take effect. | #Click '''OK''' and then '''Apply''' to have the change take effect. | ||
| Line 28: | Line 28: | ||
[[File:11.png|500px|center|thumb|Environment Variables Dialog in Windows]] | [[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| | 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) = | ||
| Line 44: | Line 44: | ||
= 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 -> Import -> | 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'''.[[File:05.png|500px|center|thumb|Import project (Eclipse)]] | ||
== IntelliJ == | == IntelliJ == | ||
Latest revision as of 01:30, 29 January 2024
READ ME FIRST
- This tutorial applies to the Windows operating system, you can also check MacOS 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.
Download and Install JavaSDK
Download JavaSDK
Go to the JavaSDK Download Page. Based on your OS, download the following file (Java 21 recommended):
Windows: x64 Installer
Install JavaSDK
Double-click the file you downloaded, you should see the following interface

Click NEXT, and choose where you want to install it. Then you wait for it to finish installing and click CLOSE.
Verify JavaSDK (Optional)
You should now find your JavaSDK installation directory e.g. C:\Program Files\Java\jdk-21\bin and copy that path.

Now you should modify environment variables on Windows.
- 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 Advanced tab, click Environment Variables.
- Choose Path under the system variables and then Click Edit to modify that environment variable.
- Click New and Paste that address (e.g.
C:\Program Files\Java\jdk-21\bin) on the textbox - Move up that textbox to the top of the list.
- Click OK and then Apply to have the change take effect.

You can now verify your JavaSDK using the terminal command java --version. You should see the following content:

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.

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 -> Settings -> plugins.

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.

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.

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:

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:

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:

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:
