<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jasta</title>
	<atom:link href="https://jasta.io/feed/" rel="self" type="application/rss+xml" />
	<link>https://jasta.io</link>
	<description>Beyond Syntax</description>
	<lastBuildDate>Mon, 22 Apr 2024 17:19:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://jasta.io/wp-content/uploads/2024/01/cropped-jasta_favicon-32x32.webp</url>
	<title>jasta</title>
	<link>https://jasta.io</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Get a Beautiful Rounded Taskbar in Windows 11</title>
		<link>https://jasta.io/how-tos/get-a-rounded-taskbar-in-windows-11/</link>
					<comments>https://jasta.io/how-tos/get-a-rounded-taskbar-in-windows-11/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Sat, 20 Apr 2024 09:07:11 +0000</pubDate>
				<category><![CDATA[How-Tos]]></category>
		<category><![CDATA[Windows 11]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2972</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to get a beautiful rounded taskbar in Windows 11, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and set up your rounded Taskbar on Windows 11.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#how-will-your-rounded-taskbar-finally-look">How Will Your Rounded Taskbar finally look</a></li><li><a href="#download-the-rounded-taskbar-program">Download the Rounded Taskbar Program</a></li><li><a href="#set-up-your-rounded-taskbar-in-windows-11">Set up Your Rounded Taskbar in Windows 11</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="how-will-your-rounded-taskbar-finally-look">How Will Your Rounded Taskbar finally look</h2>



<p>With the upgrade from Windows 10 to Windows 11, you already get more customization features for your taskbar. But you might still not be happy with the aesthetics of it. With this tutorial, you can change your taskbar from this:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="536" src="https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-1024x536.webp" alt="Default taskbar Windows 11" class="wp-image-2973" srcset="https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-1024x536.webp 1024w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-300x157.webp 300w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-768x402.webp 768w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-1536x804.webp 1536w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-2048x1072.webp 2048w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-512x268.webp 512w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-920x482.webp 920w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-1600x838.webp 1600w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar-1920x1005.webp 1920w, https://jasta.io/wp-content/uploads/2024/04/defaultTaskbar.webp 2420w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>to that:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="570" src="https://jasta.io/wp-content/uploads/2024/04/RoundedTB-1024x570.png" alt="Rounded Taskbar in Windows 11" class="wp-image-2988" srcset="https://jasta.io/wp-content/uploads/2024/04/RoundedTB-1024x570.png 1024w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-300x167.png 300w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-768x427.png 768w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-1536x855.png 1536w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-512x285.png 512w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-920x512.png 920w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-1600x890.png 1600w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB-1920x1068.png 1920w, https://jasta.io/wp-content/uploads/2024/04/RoundedTB.png 2018w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading" id="download-the-rounded-taskbar-program">Download the Rounded Taskbar Program</h2>



<p>To get a rounded taskbar in Windows 11, you first need to download RoundedTB. <a href="https://github.com/Gniang/RoundedTB/releases" target="_blank" rel="noopener">Here</a> you can find the latest released version. After opening the release page via the link provided, you have to scroll down till you see the RoundedTB_canaryXXXXXXXX_2.7z file. Just click on it and the download will start automatically. After the download is finished, you need to unzip the file to a location of your choice. Keep in mind that you download the &#8216;whole&#8217; program and not just a setup. Every file from the zip file must stay in the same location as the exe file as long as you use RoundedTB.</p>



<h2 class="wp-block-heading" id="set-up-your-rounded-taskbar-in-windows-11">Set up Your Rounded Taskbar in Windows 11</h2>



<p>After downloading and unzipping the file, you have to execute the exe file, which is located inside the extracted zip file first. You will then see a welcome window on your screen where you can just press OK to come to the final taskbar customization window.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="499" height="610" src="https://jasta.io/wp-content/uploads/2024/04/WelcomeWindow.webp" alt="RoundedTB Welcome screen" class="wp-image-2974" srcset="https://jasta.io/wp-content/uploads/2024/04/WelcomeWindow.webp 499w, https://jasta.io/wp-content/uploads/2024/04/WelcomeWindow-245x300.webp 245w" sizes="(max-width: 499px) 100vw, 499px" /></figure>
</div>


<p>After clicking OK, you will already see the configuration window, where you can set various settings. The first thing you need to decide is, whether you enable dynamic mode. When disabled the whole taskbar is configured as one element. If the dynamic mode is enabled you can customize the notification area separately. So if you want a clean taskbar with just your programs in the middle you can set the following settings to the taskbar:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="711" height="449" src="https://jasta.io/wp-content/uploads/2024/04/taskbarSettings-1.webp" alt="RoundedTB configuration taskbar" class="wp-image-2987" srcset="https://jasta.io/wp-content/uploads/2024/04/taskbarSettings-1.webp 711w, https://jasta.io/wp-content/uploads/2024/04/taskbarSettings-1-300x189.webp 300w, https://jasta.io/wp-content/uploads/2024/04/taskbarSettings-1-512x323.webp 512w" sizes="auto, (max-width: 711px) 100vw, 711px" /></figure>
</div>


<p>For the notification area you should set:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="716" height="454" src="https://jasta.io/wp-content/uploads/2024/04/notificationSettings-1.webp" alt="RoundedTB configuration notification area" class="wp-image-2986" srcset="https://jasta.io/wp-content/uploads/2024/04/notificationSettings-1.webp 716w, https://jasta.io/wp-content/uploads/2024/04/notificationSettings-1-300x190.webp 300w, https://jasta.io/wp-content/uploads/2024/04/notificationSettings-1-512x325.webp 512w" sizes="auto, (max-width: 716px) 100vw, 716px" /></figure>
</div>


<p>Now only your actual taskbar with your programs will be visible. The notification area will appear as soon as you hover over it with your mouse. Also, don&#8217;t forget to disable Widgets for your taskbar, otherwise only one-half of the taskbar will be gone. This can be done via settings -> personalization -> taskbar -> taskbar items.</p>



<p>If you still find your taskbar kind of weird looking, try to open the taskbar settings and change the alignment to left and then back to right. Now everything should look normal.</p>



<p>The last thing you need to do is automatically start the program when booting your computer. For that, you just have to right-click on the program icon in the notification area and check &#8216;Run at startup&#8217;.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="232" height="222" src="https://jasta.io/wp-content/uploads/2024/04/Screenshot-2024-04-22-161813.png" alt="RoundedTB run at startup" class="wp-image-2979"/></figure>
</div>


<p><strong>Important:</strong> If you update from a previous version, you need to delete or rename the old settings file of RoundedTB, since this is not compatible with this new version. It is located in %USERPROFILE%\APPDATA\Local\. The name of the file is rtb.json. </p>



<p>Now you have a rounded taskbar in Windows 11, which should look like the taskbar in the screenshot at the beginning of the tutorial. Should you encounter any questions or challenges, don’t hesitate to reach out. Your feedback, queries, and insights are always valued, and I’m here to assist you. Until next time!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/how-tos/get-a-rounded-taskbar-in-windows-11/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Writing Unit Tests in Java with JUnit 5: A Comprehensive Guide</title>
		<link>https://jasta.io/java-basics/writing-unit-tests-in-java-with-junit-5/</link>
					<comments>https://jasta.io/java-basics/writing-unit-tests-in-java-with-junit-5/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Sun, 14 Apr 2024 14:51:39 +0000</pubDate>
				<category><![CDATA[Java Basics]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JUnit 5]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2943</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to write unit tests in Java with JUnit 5, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and start writing unit tests in Java with JUnit 5.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#why-you-should-implement-unit-tests-for-your-java-application">Why You Should Implement Unit Tests for Your Java Application</a></li><li><a href="#most-important-annotations-for-j-unit-5-tests-in-java">Most Important Annotations for JUnit 5 tests in Java</a></li><li><a href="#step-by-step-guide-to-writing-unit-tests-in-java-with-j-unit-5">Step-by-Step Guide to Writing Unit Tests in Java with JUnit 5</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="why-you-should-implement-unit-tests-for-your-java-application">Why You Should Implement Unit Tests for Your Java Application</h2>



<p>In modern software development, unit testing stands as an indispensable pillar of ensuring code quality and reliability. At its core, unit testing involves the systematic validation of individual units or components of a software application, typically at the function or method level. The primary goal? To verify that each unit behaves exactly as intended under various conditions, effectively contributing to the overall functionality of the system.</p>



<p>Writing unit tests in Java with JUnit 5 offers a structured approach to this crucial aspect of software engineering. By meticulously crafting tests to assess the behavior of isolated code units, developers gain invaluable insights into the correctness and robustness of their implementations. But why is unit testing so vital, especially in the context of Java development with JUnit 5?</p>



<p>First and foremost, unit testing serves as an early warning system, flagging potential bugs and errors in the codebase long before they manifest into critical issues in a production environment. By identifying and rectifying these issues early in the development lifecycle, developers can significantly reduce the time and effort spent on debugging and troubleshooting later stages.</p>



<p>Moreover, unit testing fosters a culture of confidence and trust in the codebase. Each passing test provides a tangible affirmation that a particular piece of functionality works as expected, instilling a sense of assurance among developers and stakeholders alike. This confidence translates into smoother integration processes, as developers can confidently integrate their changes knowing that existing functionality remains intact.</p>



<p>Furthermore, writing unit tests in Java with JUnit 5 facilitates seamless code maintenance and refactoring. As software projects evolve over time, developers often need to make changes to existing code to accommodate new requirements or optimize performance. Unit tests act as a safety net, ensuring that modifications do not inadvertently introduce regressions or break existing functionality.</p>



<p>In summary, unit testing with JUnit 5 is not merely a best practice; it&#8217;s a fundamental aspect of modern software development. By validating individual units of code in isolation, developers can uncover defects early, build confidence in their codebase, and facilitate seamless maintenance and evolution of software projects.</p>



<h2 class="wp-block-heading" id="most-important-annotations-for-j-unit-5-tests-in-java">Most Important Annotations for JUnit 5 tests in Java</h2>



<p>In JUnit 5, annotations play an important role in defining the behavior and structure of unit tests. Understanding and effectively utilizing these annotations is essential for writing clear, concise, and maintainable test code. Below, are some important annotations that are necessary for writing unit tests in Java with JUnit 5.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@Test</pre>



<p>This annotation is used to mark a method as a test method. JUnit 5 will execute all methods annotated with @Test.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@BeforeEach</pre>



<p>Methods annotated with @BeforeEach are executed before each test method in the class. They are typically used to set up common test fixtures or initialize resources.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@AfterEach</pre>



<p>Methods annotated with @AfterEach are executed after each test method in the class. They are commonly used to clean up resources or reset the state after each test.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@BeforeAll</pre>



<p>Methods annotated with @BeforeAll are executed once before all test methods in the class. They are used for setup operations that are performed once for the entire test class.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@AfterAll</pre>



<p>Methods annotated with @AfterAll are executed once after all test methods in the class have been executed. They are typically used for cleanup operations that need to be performed once after all tests have finished.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@Disabled</pre>



<p>Methods annotated with @Disabled are skipped during test execution. This annotation is useful for temporarily excluding tests that are not ready or relevant</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">@ExtendWith</pre>



<p>Used to register extensions with JUnit 5 tests, @ExtendWith allows you to customize the behavior of test classes or methods by applying additional functionality provided by extensions.</p>



<h2 class="wp-block-heading" id="step-by-step-guide-to-writing-unit-tests-in-java-with-j-unit-5">Step-by-Step Guide to Writing Unit Tests in Java with JUnit 5</h2>



<p>In this tutorial, we are writing unit tests in Java with JUnit 5 for our FileHelper from the <a href="https://jasta.io/java-basics/reading-files-in-java/">reading</a> and <a href="https://jasta.io/java-basics/writing-to-files-in-java/">writing</a> to files in Java tutorials. You can find the full code of the FileHelper class <a href="https://github.com/jastaio/JavaTutorials/blob/main/FileReaderWriter/src/main/java/FileHelper.java" target="_blank" rel="noopener">here</a> on our GitHub repository.</p>



<p>To start, we must create a class that will later contain all the tests. This can be automatically done. For that, you need to open the class which should be tested and press CTRL+SHIFT+T on your keyboard. Now a small menu will appear where you can click on create new test. Then a configuration window is going to show on your screen. With that configurator, you can choose the JUnit version, the class name, a superclass, and the destination package and you can even auto-generate the setup and teardown methods and create test methods for the methods inside the class.</p>



<p>For this tutorial, we are just choosing the correct version and the class name. The rest will be left empty.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="437" height="469" src="https://jasta.io/wp-content/uploads/2024/04/JUnit5ClassConfiguration.webp" alt="" class="wp-image-2950" srcset="https://jasta.io/wp-content/uploads/2024/04/JUnit5ClassConfiguration.webp 437w, https://jasta.io/wp-content/uploads/2024/04/JUnit5ClassConfiguration-280x300.webp 280w" sizes="auto, (max-width: 437px) 100vw, 437px" /></figure>
</div>


<p>For our FileHelper we want to test both read and write methods. All of the methods have a Path as a method parameter so we first need to create a file within a directory that can be used for testing. To not have to worry about deleting the directory after all the tests, we are using the @TempDir annotation. This will generate a temporary directory when starting the tests. After all the tests run through, the directory will be deleted automatically. Without this annotation it would be necessary, to create the directory in the @BeforeAll method and delete it in the @AfterAll method.</p>



<p>In addition to the directory that will contain the file, we are also declaring a file name, the file for the tests itself and the file content in the test class. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  @TempDir
  private File tempDir;
  private final String fileName = "tempFile.txt";
  private File tempFile = new File(tempDir, fileName);;
  private final List&lt;String> testContent = List.of("Hello World!", "This is a test.");</pre>



<p>After declaring every necessary variable in the class we are creating the @BeforeEach and @AfterEach method. In these methods, we are going to create/delete the file that will be used for the tests.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  @BeforeEach
  void setUp() throws IOException {
    tempFile.createNewFile();
  }

  @AfterEach
  void tearDown() {
    tempFile.delete();
  }</pre>



<p>Now we are going to test our methods of the FileWriter class. Since the FileWriter class has read and write methods implemented with java.nio and java.io, we are going to test these in two different tests. </p>



<p>To create a unit test you need to write a method that does something to begin with. In this case, this would be FileHelper.writeToFile and FileHelper.readFromFile. To make this method a test you need to add a @Test annotation above the method declaration. Now the method is already a valid test which calls a method but doesn&#8217;t check if the method is actually working. Therefore we are adding an assertEquals call which will check if the file content written and then read by our FileHelper has the same amount of lines. Furthermore, we are iterating through the read results and checking if it is equal to the content we wanted to write with the FileHelper.</p>



<p>If all these assertions are correct, we know that the writing and reading of files is working correctly. The same checks are also done in the test method for the java.io FileWriter methods.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  @Test
  void testFileWriter() {
    FileHelper.writeToFile(tempFile.getAbsolutePath(), String.join("\n", testContent));
    List&lt;String> fileContent = FileHelper.readFromFile(tempFile.getAbsolutePath());

    assertEquals(testContent.size(), fileContent.size());

    for (int i = 0; i &lt; testContent.size(); i++) {
      assertEquals(testContent.get(i), fileContent.get(i));
    }
  }

  @Test
  void testBufferedFileWriter() {
    FileHelper.writeToFileBufferedWriter(tempFile.getAbsolutePath(),
        String.join("\n", testContent));
    List&lt;String> fileContent = FileHelper.readFromFileBufferedReader(tempFile.getAbsolutePath());

    assertEquals(testContent.size(), fileContent.size());

    for (int i = 0; i &lt; testContent.size(); i++) {
      assertEquals(testContent.get(i), fileContent.get(i));
    }
  }</pre>



<p>To prevent code duplications, the checks can also be done in a separate method which is called by a test method. The code would then look like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  @Test
  void testFileWriter() {
    FileHelper.writeToFile(tempFile.getAbsolutePath(), String.join("\n", testContent));
    checkReadResult(FileHelper.readFromFile(tempFile.getAbsolutePath()));
  }

  @Test
  void testBufferedFileWriter() {
    FileHelper.writeToFileBufferedWriter(tempFile.getAbsolutePath(),
        String.join("\n", testContent));
    checkReadResult(FileHelper.readFromFileBufferedReader(tempFile.getAbsolutePath()));
  }

  private void checkReadResult(List&lt;String> actualContent) {
    assertEquals(testContent.size(), actualContent.size());

    for (int i = 0; i &lt; testContent.size(); i++) {
      assertEquals(testContent.get(i), actualContent.get(i));
    }
  }</pre>



<p>It&#8217;s also possible to assert Exceptions to test invalid parameters given to the FileHelper. Instead of assertEquals you can use assertThrows with the expected exception class, an executable code and you can also add an error message to all of your assertions. It is also possible to check the exception message because assertThrows returns the occurred exception.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  @Test
  void readFromFileError() {
    RuntimeException e = assertThrows(RuntimeException.class,
        () -> FileHelper.readFromFile(tempDir.getAbsolutePath()),
        "Exception was not thrown!");

    assertEquals(e.getCause().getMessage(), "The file cannot be accessed!");
  }

  @Test
  void readFromFileBufferedReaderError() {
    assertThrows(RuntimeException.class,
        () -> FileHelper.readFromFileBufferedReader(tempDir.getAbsolutePath()),
        "Exception was not thrown!");
  }</pre>



<p>Your full test class should now be the same as the code below. You can also find the complete code <a href="https://github.com/jastaio/JavaTutorials/blob/main/FileReaderWriter/src/test/java/FileHelperTest.java" target="_blank" rel="noopener">here</a>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
import java.io.IOException;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

class FileHelperTest {

  @TempDir
  private File tempDir;
  private final String fileName = "tempFile.txt";
  private File tempFile = new File(tempDir, fileName);;
  private final List&lt;String> testContent = List.of("Hello World!", "This is a test.");

  @BeforeEach
  void setUp() throws IOException {
    tempFile.createNewFile();
  }

  @AfterEach
  void tearDown() {
    tempFile.delete();
  }

  @Test
  void testFileWriter() {
    FileHelper.writeToFile(tempFile.getAbsolutePath(), String.join("\n", testContent));
    checkReadResult(FileHelper.readFromFile(tempFile.getAbsolutePath()));
  }

  @Test
  void testBufferedFileWriter() {
    FileHelper.writeToFileBufferedWriter(tempFile.getAbsolutePath(),
        String.join("\n", testContent));
    checkReadResult(FileHelper.readFromFileBufferedReader(tempFile.getAbsolutePath()));
  }

  private void checkReadResult(List&lt;String> actualContent) {
    assertEquals(testContent.size(), actualContent.size());

    for (int i = 0; i &lt; testContent.size(); i++) {
      assertEquals(testContent.get(i), actualContent.get(i));
    }
  }

  @Test
  void readFromFileError() {
    RuntimeException e = assertThrows(RuntimeException.class,
        () -> FileHelper.readFromFile(tempDir.getAbsolutePath()),
        "Exception was not thrown!");

    assertEquals(e.getCause().getMessage(), "The file cannot be accessed!");
  }

  @Test
  void readFromFileBufferedReaderError() {
    assertThrows(RuntimeException.class,
        () -> FileHelper.readFromFileBufferedReader(tempDir.getAbsolutePath()),
        "Exception was not thrown!");
  }
}</pre>



<p>Now that your test class is ready, you can execute the whole test class with all the tests with the green arrow next to the class name inside the code or just run a single test method with the green arrow next to the method declaration.</p>



<p>When the tests are finished you will see the result of them in the run window at the bottom of your IDE as shown in the screenshot below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="209" src="https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava-1024x209.webp" alt="Writing Unit Tests in Java with JUnit 5" class="wp-image-2947" srcset="https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava-1024x209.webp 1024w, https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava-300x61.webp 300w, https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava-768x157.webp 768w, https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava-512x104.webp 512w, https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava-920x188.webp 920w, https://jasta.io/wp-content/uploads/2024/04/JUnit5TestsInJava.webp 1054w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>If you don&#8217;t see each test method result but only the test class, you have to switch from running unit tests with Gradle to running them with IntelliJ IDEA. To do this you first have to open the settings of IntelliJ. This can be done with CTRL+ALT+S or via the top menu under &#8216;File&#8217;. After opening the settings window, you need to find &#8216;Build, Execution, Deployment&#8217; on the left side, expand it, find Build Tools and click on Gradle. In the window after clicking on Gradle you can now set &#8216;Run tests using:. Choose IntelliJ IDEA from the drop-down menu and click OK. </p>



<p>If you now run your unit tests you will see every single test listed on the run window.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="975" height="729" src="https://jasta.io/wp-content/uploads/2024/04/IntelliJ_runTestsWithIntelliJIDEA.webp" alt="Run unit tests with IntelliJ IDEA" class="wp-image-2946" srcset="https://jasta.io/wp-content/uploads/2024/04/IntelliJ_runTestsWithIntelliJIDEA.webp 975w, https://jasta.io/wp-content/uploads/2024/04/IntelliJ_runTestsWithIntelliJIDEA-300x224.webp 300w, https://jasta.io/wp-content/uploads/2024/04/IntelliJ_runTestsWithIntelliJIDEA-768x574.webp 768w, https://jasta.io/wp-content/uploads/2024/04/IntelliJ_runTestsWithIntelliJIDEA-512x383.webp 512w, https://jasta.io/wp-content/uploads/2024/04/IntelliJ_runTestsWithIntelliJIDEA-920x688.webp 920w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>
</div>


<p>If a unit test fails you will also be able to see the difference in the result window, so you don&#8217;t have to debug into the test to see what values are getting compared or checked.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="253" src="https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest-1024x253.webp" alt="" class="wp-image-2951" srcset="https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest-1024x253.webp 1024w, https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest-300x74.webp 300w, https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest-768x190.webp 768w, https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest-512x127.webp 512w, https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest-920x228.webp 920w, https://jasta.io/wp-content/uploads/2024/04/JUnit5FailedTest.webp 1091w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>As we wrap up our journey through the process of writing unit tests in Java with JUnit 5, I hope you&#8217;ve found this guide insightful and helpful in enhancing your knowledge. Should you encounter any questions or challenges while implementing, don&#8217;t hesitate to reach out. Your feedback, queries, and insights are always valued, and I&#8217;m here to assist you on your coding adventures. Until next time, happy coding!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/java-basics/writing-unit-tests-in-java-with-junit-5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Implement Powerful Logging in Java with Log4j2</title>
		<link>https://jasta.io/java-basics/logging-in-java-with-log4j2/</link>
					<comments>https://jasta.io/java-basics/logging-in-java-with-log4j2/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Thu, 04 Apr 2024 15:57:50 +0000</pubDate>
				<category><![CDATA[Java Basics]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2902</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to implement logging in Java with Log4j2, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and start implementing logging in Java with Log4j2.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#why-proper-logging-is-necessary-for-every-application">Why Proper Logging is Necessary for Every Application</a></li><li><a href="#adding-log-4-j-2-dependencies-to-your-project">Adding Log4j2 Dependencies to Your Project</a></li><li><a href="#implement-logging-in-java-with-log-4-j-2">Implement Logging in Java with Log4j2</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="why-proper-logging-is-necessary-for-every-application">Why Proper Logging is Necessary for Every Application</h2>



<p>Proper logging is indispensable for every application as it serves as a crucial lifeline for developers and operators alike. Logging provides a detailed record of system behavior, errors, and events, aiding in troubleshooting and debugging processes. It offers insights into the application&#8217;s health, performance, and usage patterns, enabling developers to identify and rectify issues promptly. </p>



<p>Moreover, comprehensive logs enhance security by facilitating the detection of suspicious activities or breaches. In essence, robust logging practices not only enhance the reliability and maintainability of an application but also contribute significantly to its overall security and performance. </p>



<h2 class="wp-block-heading" id="adding-log-4-j-2-dependencies-to-your-project">Adding Log4j2 Dependencies to Your Project</h2>



<p>Before implementing logging in Java with Log4j2 you first need to add certain dependencies to your <a href="https://jasta.io/java-basics/create-your-first-java-program-with-ease/">Java project</a> so that you can use Log4j2. If you are using Kotlin as your DSL you can copy the required dependencies from below. If you use any other language you can find the correct dependency implementation on the Maven repository. To follow this tutorial you need the <a href="https://mvnrepository.com/artifact/org.slf4j/slf4j-api/2.0.12" target="_blank" rel="noopener">slf4j-api dependency</a> and the <a href="https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j2-impl/2.23.1" target="_blank" rel="noopener">log4j-slf4j2-impl</a>. The dependencies need to be added to your build.gradle if you use Gradle or to your pom.xml if you use Maven.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="kotlin" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">    implementation("org.slf4j:slf4j-api:2.0.12")
    implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1")</pre>



<h2 class="wp-block-heading" id="implement-logging-in-java-with-log-4-j-2">Implement Logging in Java with Log4j2</h2>



<p>The first thing you need to do to implement logging in Java with Log4j2 is, to create a configuration file. In that file, you need to define different settings like log levels, different log appenders and settings for these like a Rollover strategy. The file must be placed in your application&#8217;s resources folder and named &#8216;log4j2&#8217;. The file type is XML. After the creation, it should look like the red highlighted file below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="381" height="319" src="https://jasta.io/wp-content/uploads/2024/04/log4j2ConfigurationFile.webp" alt="Log4j2.xml configuration" class="wp-image-2910" srcset="https://jasta.io/wp-content/uploads/2024/04/log4j2ConfigurationFile.webp 381w, https://jasta.io/wp-content/uploads/2024/04/log4j2ConfigurationFile-300x251.webp 300w" sizes="auto, (max-width: 381px) 100vw, 381px" /></figure>
</div>


<p>Inside the file, you can now define different configurations. For example, you can create a File logger or configure it, to log everything in the application console. But you can also configure multiple loggers. All the different configurations can be found on the <a href="https://logging.apache.org/log4j/2.x/manual/appenders.html" target="_blank" rel="noopener">website of Apache about log4j2.</a></p>



<p>In this tutorial, we are going to create a file logger. The file logger will be configured with a SizeBasedTriggeringPolicy which means that if the current log file of the app is bigger than the configured value, a new log file will be created and the &#8216;full&#8217; one will be saved. We are also adding a DefaultRolloverStrategy. With that, it can be prevented that hundreds of &#8216;full&#8217; log files are being created. You can have different conditions to delete old log files like a maximum amount, an age limitation and many more.</p>



<p>You can copy the full code of the file logger configuration from the <a href="https://github.com/jastaio/JavaTutorials/tree/main/Log4jTest" target="_blank" rel="noopener">jasta GitHub repository</a> or from below. Carefully read the comments in the XML file to fully understand the meaning of each line inside the file, configure it to your requirements, and implement your custom logging in Java with Log4j2.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;!--
Status defines the level of internal Log4j events that should be logged to the console.
If there are any configuration problems without an obvious error you can set it to trace or other levels.
Valid values are: off, trace, debug, info, warn, error, fatal, all
-->
&lt;Configuration status="info">
  &lt;Properties>
    &lt;!-- 
    The path of the log directory. With the configuration below, the log files are stored under 
    &lt;drive>:\logs
    -->
    &lt;Property name="LOG_DIR">/logs&lt;/Property>
  &lt;/Properties>

  &lt;Appenders>
    &lt;!--
     name: The name of the appender
     fileName: The name of the current log file
     filePattern: The file names of any older log which is created if the current log size exceeds the SizeBasedTriggeringPolicy
     immediateFlush: Log is written as soon as the log methods are called
     -->
    &lt;RollingFile
      name="fileLogger"
      fileName="${LOG_DIR}/AppCurrent.log"
      filePattern="${LOG_DIR}/App_%d{yyyy-MM-dd_hh-mm-ss}.log"
      immediateFlush="true">
      &lt;PatternLayout>
        &lt;!--
        The format of the log message inside the file
        Example: 2024-04-04 18:57:29.369 [Bank.register] [INFO] WorldBank Germany - Customer 'Id' successfully registered!
        Definition: &lt;Date with Time> [&lt;ClassName>.&lt;Method>] [&lt;Message Log Level>] &lt;LoggerName> - &lt;Message>
        -->
        &lt;Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%C{1}.%M] [%level] %logger{36} - %msg%n&lt;/Pattern>
      &lt;/PatternLayout>
      &lt;Policies>
        &lt;!-- Maximum size of the current log file -->
        &lt;SizeBasedTriggeringPolicy size="10MB"/>
      &lt;/Policies>

      &lt;!-- Rollover strategy to delete old log files -->
      &lt;DefaultRolloverStrategy>
        &lt;!-- Search path for the deletion and depth (1 = just the search path not any subfolders, -1: search path with every subfolder, 2,3,4...: search path with x subfolders -->
        &lt;Delete basePath="${LOG_DIR}" maxDepth="1">
          &lt;!-- File name pattern for the old log files -->
          &lt;IfFileName glob="App_*.log"/>
          &lt;!-- Maximum amount of old log file -->
          &lt;IfAccumulatedFileCount exceeds="10"/>
        &lt;/Delete>
      &lt;/DefaultRolloverStrategy>
    &lt;/RollingFile>
  &lt;/Appenders>

  &lt;Loggers>
    &lt;!--
    The log level of the root logger which will be applied to the child logger.
    With info log messages with .info, .error, .warn are logged - .debug for example will not get logged
    Valid values are: off, trace, debug, info, warn, error, fatal, all
    -->
    &lt;Root level="info">
      &lt;!-- Add the appender via its name -->
      &lt;AppenderRef ref="fileLogger"/>
    &lt;/Root>
  &lt;/Loggers>
&lt;/Configuration></pre>



<p>After you have copied the code above or configured it to your requirements, you can start logging in Java with Log4j2. Therefore you have to call LoggerFactory.getLogger(&lt;ConstructorParameter>) with either a class or a String as a constructor parameter. The given Parameter will be the name of the logger. The returned Object will be a Logger Object from org.slf4j.Logger. You can now call different log methods like debug, error, info, warn, trace and many more. Depending on what log level is set in the configuration file some messages will not get logged. All available methods can be seen <a href="https://www.slf4j.org/api/org/slf4j/Logger.html" target="_blank" rel="noopener">here</a>.</p>



<p>An example declaration would look like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">private static final Logger LOGGER = LoggerFactory.getLogger(TestDriver.class);</pre>



<p>Later the Logger object can be used like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">LOGGER.info("Application is starting...");</pre>



<p>If you are logging much, your log output directory will look similar to the screenshot below. As you can see, a new log file is created after 10KB (in this case 11KB since it is such a small unit. With MB it would not be 11MB). Also, the old log files are created with the date and time as configured in the log4j2.xml file. Furthermore, the limit of 10 old log files is also considered. If a new log file were to be created, the oldest log file, in this case &#8216;App_2024-04-06_05-13-05.log&#8217;, would be deleted.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="610" height="348" src="https://jasta.io/wp-content/uploads/2024/04/LogFileLog4j.webp" alt="Logging in Java with Log4j2" class="wp-image-2911" srcset="https://jasta.io/wp-content/uploads/2024/04/LogFileLog4j.webp 610w, https://jasta.io/wp-content/uploads/2024/04/LogFileLog4j-300x171.webp 300w, https://jasta.io/wp-content/uploads/2024/04/LogFileLog4j-512x292.webp 512w" sizes="auto, (max-width: 610px) 100vw, 610px" /></figure>
</div>


<p>This was the process of implementing logging in Java with Log4j2. If you have any questions or trouble implementing your logging system feel free to leave a comment below.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/java-basics/logging-in-java-with-log4j2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Writing to Files in Java: Master File Operations with Ease</title>
		<link>https://jasta.io/java-basics/writing-to-files-in-java/</link>
					<comments>https://jasta.io/java-basics/writing-to-files-in-java/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Fri, 29 Mar 2024 17:29:15 +0000</pubDate>
				<category><![CDATA[Java Basics]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2872</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into writing to files in Java, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and start writing to files in Java.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#the-importance-of-writing-to-files-in-java">The Importance of Writing to Files in Java</a></li><li><a href="#implement-different-ways-to-write-to-files">Implement Different Ways to Write to Files</a><ul><li><a href="#java-nio-files">Java NIO Files</a></li><li><a href="#buffered-writer-with-file-writer">BufferedWriter with FileWriter</a></li></ul></li></ul></nav></div>



<h2 class="wp-block-heading" id="the-importance-of-writing-to-files-in-java">The Importance of Writing to Files in Java</h2>



<p>In the world of software development, the ability to write data to files in Java plays a vital role in managing and preserving valuable information. This aspect is often considered the counterpart to reading files, as it enables developers to not only access existing data but also store new or modified data for future use.</p>



<p>When we talk about writing files in Java, we&#8217;re essentially talking about the process of saving data to different types of files, be it plain text files, structured data files like CSV or XML, or even binary files. This capability is crucial for a wide range of applications. For instance, in a logging scenario, writing critical events to a log file ensures that important information is recorded for debugging or auditing purposes.</p>



<p>Moreover, writing to files in Java facilitates data persistence, ensuring that essential data isn&#8217;t lost between application sessions. This is particularly crucial for applications that require user preferences or settings to be saved, allowing users to seamlessly resume their activities without losing their custom configurations.</p>



<p>Beyond basic data storage, Java&#8217;s file writing capabilities extend to creating structured outputs in formats suitable for sharing and collaboration. For example, generating reports in PDF or Excel formats allows users to analyze and share data insights efficiently. This ability to produce structured outputs enhances the usability and versatility of Java-powered applications across various domains.</p>



<p>Mastering the art of writing to files in Java empowers developers to design robust and efficient software solutions that not only capture and retain crucial data but also unleash the full potential of their applications to deliver impactful insights and drive innovation.</p>



<h2 class="wp-block-heading" id="implement-different-ways-to-write-to-files">Implement Different Ways to Write to Files</h2>



<p>For reading files in Java there are two different approaches. One uses Java.io which is available since version 1.1 and the other uses a method of Java.nio which was introduced with version  1.7.</p>



<h3 class="wp-block-heading" id="java-nio-files">Java NIO Files</h3>



<p>The more modern and easy solution for writing to files in Java is Java.nio.Files. With that, you can call the static method write from Files with a Path parameter, the content as a byte array and OpenOptions. Via the OpenOptions you can decide what should happen if the file already exists/not exists. There are many different options like Create, Create_New and Append. You can find all the options with a description <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html" target="_blank" rel="noopener">here</a>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  public static void writeToFile(String path, String content) {
    try {
      Files.write(Path.of(path), content.getBytes(), StandardOpenOption.CREATE);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }</pre>



<h3 class="wp-block-heading" id="buffered-writer-with-file-writer">BufferedWriter with FileWriter</h3>



<p>The more traditional and sometimes necessary way with a Java version below 1.7 is with a BufferedWriter and a FileWriter. After initializing the BufferedWriter with the FileWriter the write method of the BufferedWriter has to be called with the content as a String. After the method call the BufferedWriter has to be closed via its close method.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  public static void writeToFileBufferedWriter(String path, String content) {
    File fileToWrite = new File(path);
    try {
      boolean fileExists = fileToWrite.exists();
      if (!fileExists) {
        fileExists = fileToWrite.createNewFile();
      }

      if (fileExists &amp;&amp; fileToWrite.isFile() &amp;&amp; fileToWrite.canWrite()) {
        BufferedWriter writer = new BufferedWriter(new FileWriter(fileToWrite));
        writer.write(content);
        writer.close();
      } else {
        throw new RuntimeException(new IOException("The file cannot be accessed!"));
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }</pre>



<p>You can also find the whole code on the <a href="https://github.com/jastaio/JavaTutorials/tree/main/FileReaderWriter" target="_blank" rel="noopener">jasta GitHub repository</a>. To also learn how to read files in Java you can click <a href="https://jasta.io/java-basics/reading-files-in-java/">here</a>. If you have any questions or feedback feel free to comment below. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/java-basics/writing-to-files-in-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Reading Files in Java: Unleash Data Insights Effortless</title>
		<link>https://jasta.io/java-basics/reading-files-in-java/</link>
					<comments>https://jasta.io/java-basics/reading-files-in-java/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Fri, 29 Mar 2024 17:29:08 +0000</pubDate>
				<category><![CDATA[Java Basics]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2873</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into reading files in Java, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and start reading files in Java.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#the-importance-of-reading-files-in-java">The Importance of Reading Files in Java</a></li><li><a href="#implement-different-ways-to-read-files">Implement Different Ways to Read Files</a><ul><li><a href="#java-nio-files">Java NIO Files</a></li><li><a href="#buffered-reader-with-file-reader">BufferedReader with FileReader</a></li></ul></li></ul></nav></div>



<h2 class="wp-block-heading" id="the-importance-of-reading-files-in-java">The Importance of Reading Files in Java</h2>



<p>In the realm of software development, the ability to efficiently read and process data from files is a fundamental skill, and Java equips developers with powerful tools to accomplish this task seamlessly.</p>



<p>Reading files in Java is not merely a technical necessity; it is a gateway to unlocking valuable insights and harnessing the potential of diverse data sources. Whether it&#8217;s parsing configuration files, analyzing log data, or extracting information from structured documents, Java&#8217;s file reading capabilities play a pivotal role in enabling developers to interact with data stored in various formats.</p>



<p>From plain text files to complex binary formats, Java offers versatile mechanisms for accessing and manipulating file contents. Moreover, Java&#8217;s support for popular data interchange formats such as JSON and XML further enhances its utility in modern software development.</p>



<p>JSON and XML, being widely adopted for their simplicity and flexibility in representing structured data, find extensive use in web services, configuration files, and data exchange between different systems. By adeptly reading and processing files in Java, developers can seamlessly integrate these data formats into their applications, thereby facilitating interoperability and enhancing the overall functionality and usability of their software solutions.</p>



<p>In essence, mastering the art of reading files in Java is not merely about manipulating bytes and characters; it&#8217;s about harnessing the potential of data to drive innovation, gain insights, and deliver impactful software solutions.</p>



<h2 class="wp-block-heading" id="implement-different-ways-to-read-files">Implement Different Ways to Read Files</h2>



<p>For reading files in Java there are two different approaches. One uses Java.io which is available since version 1.1 and the other uses a method of Java.nio which was introduced with version  1.7.</p>



<h3 class="wp-block-heading" id="java-nio-files">Java NIO Files</h3>



<p>The more modern and easy solution for reading files in Java is Java.nio.Files. With that, you can call the static method readAllLines from Files with a Path parameter. A Path can be created via toPath on a File object or with Path.of(&lt;FilePathAsString&gt;). Optionally you can add a Charset after the path as well. It returns a list of strings where one entry represents one line in the file.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  public static List&lt;String> readFromFile(String path) {
    File fileToRead = new File(path);

    if (fileToRead.exists() &amp;&amp; fileToRead.isFile() &amp;&amp; fileToRead.canRead()) {
      try {
        return Files.readAllLines(fileToRead.toPath());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } else {
      throw new RuntimeException(new IOException("The file cannot be accessed!"));
    }
  }</pre>



<h3 class="wp-block-heading" id="buffered-reader-with-file-reader">BufferedReader with FileReader</h3>



<p>The more traditional and sometimes necessary way with a Java version below 1.7 is with a BufferedReader and a FileReader. After initializing the BufferedReader with the FilleReader the readLine method of the BufferedReader has to be called to get the next line. When the file ends, the method will return null. After the end of the file is reached the BufferedReader has to be closed.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  public static List&lt;String> readFromFileBufferedReader(String path) {
    File fileToRead = new File(path);

    if (fileToRead.exists() &amp;&amp; fileToRead.isFile() &amp;&amp; fileToRead.canRead()) {
      try {
        BufferedReader reader = new BufferedReader(new FileReader(fileToRead));
        String temp;
        List&lt;String> content = new ArrayList&lt;>();

        while ((temp = reader.readLine()) != null) {
          content.add(temp);
        }

        reader.close();

        return content;
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } else {
      throw new RuntimeException(new IOException("The file cannot be accessed!"));
    }
  }</pre>



<p>You can also find the whole code on the <a href="https://github.com/jastaio/JavaTutorials/tree/main/FileReaderWriter" target="_blank" rel="noopener">jasta GitHub repository</a>. You can also click <a href="https://jasta.io/java-basics/writing-to-files-in-java/">here</a> to learn how to write to files in Java. If you have any questions or feedback feel free to comment below. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/java-basics/reading-files-in-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mastering Java Objects: Comprehensive Guide to Constructors, Getters, and Setters</title>
		<link>https://jasta.io/java-basics/mastering-java-objects-a-comprehensive-guide/</link>
					<comments>https://jasta.io/java-basics/mastering-java-objects-a-comprehensive-guide/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Sun, 24 Mar 2024 17:16:15 +0000</pubDate>
				<category><![CDATA[Java Basics]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2854</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to create and use Java Objects, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and start coding with Java Objects.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#what-are-java-objects-and-why-do-they-exist">What are Java Objects and Why Do They Exist?</a></li><li><a href="#understanding-the-purpose-of-constructors-in-java">Understanding the Purpose of Constructors in Java</a></li><li><a href="#how-to-create-and-use-java-objects">How to Create and Use Java Objects</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="what-are-java-objects-and-why-do-they-exist">What are Java Objects and Why Do They Exist?</h2>



<p>As you might already know, there are some predefined objects in Java. Examples would be a String which stores some text or an Integer which can store a number. These are already pretty useful but what would you do, if you want to store multiple pieces of information for one thing? An example would be a car. All necessary information cannot be stored inside a String or an Integer. So the best approach is to create a new Object which cannot just store one particular information but many different things.</p>



<p>Regarding the car example some things that should be stored would be:</p>



<ul class="wp-block-list">
<li>Brand</li>



<li>Model</li>



<li>Plate</li>



<li>Color</li>



<li>Seats</li>



<li>Steering wheel</li>
</ul>



<p>Of course, there are many more things, but this is enough for the beginning. Some of the info can be easily stored in a string like the brand or the model whereas others require more details like the seats and steering wheel. This is because seats can come in various configurations for example with heating or without. That is also the case for the steering wheel. Therefore we would also need to create custom Java objects for the seats and the steering wheel.</p>



<h2 class="wp-block-heading" id="understanding-the-purpose-of-constructors-in-java">Understanding the Purpose of Constructors in Java</h2>



<p>Before actually creating your first Java Objects you have to know about constructors. A constructor is called at the very beginning of creating an object. It is called once and then never again. The purpose of it is to set some variables in the object or execute functions that are necessary at the beginning. Variables that are given with the constructor to the Java Object are often:</p>



<ul class="wp-block-list">
<li>Values that must be set before any method call</li>



<li>Values that are already known upon the creation of the object</li>



<li>Values that are used for a method call inside the constructor </li>
</ul>



<p>To get back to the car example a constructor would look like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  public Car(String brand, String model) {
    this.brand = brand;
    this.model = model;
  }</pre>



<p>With that constructor, we are already setting the brand and the model inside the car object since this information is already known on creation. Other information is probably not known when starting with the creation of the car.</p>



<p>Good to know is, if there is no constructor defined in a class it is the same as an empty constructor. But there can also be multiple constructor definitions.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  public Car(String brand, String model) {
    this.brand = brand;
    this.model = model;
  }  
  
  public Car(String brand, String model, String color) {
    this.brand = brand;
    this.model = model;
    this.color = color;
  }</pre>



<p>In the example above you have two constructors so you can create an object with these options depending on if you already know the color. In the code a new car object can now be created via &#8216;new Car(&#8220;Audi&#8221;, &#8220;A4&#8221;);&#8217; or &#8216;new Car(&#8220;Audi&#8221;, &#8220;A4&#8221;, &#8220;Green&#8221;);&#8217;.</p>



<p>The difference between a constructor and a setter method is, that a constructor is once called when creating an object. A setter method can be but must not be called after initializing the object and can also be called multiple times with different values.</p>



<h2 class="wp-block-heading" id="how-to-create-and-use-java-objects">How to Create and Use Java Objects</h2>



<p>Now let&#8217;s implement the car example with Java Objects. The complete code can be found and cloned from the <a href="https://github.com/jastaio/JavaTutorials/tree/main/CarProduction" target="_blank" rel="noopener">jasta GitHub repository</a>. To begin with we have to create our objects by creating new classes. If you don&#8217;t know how to create classes in IntelliJ IDEA click <a href="https://jasta.io/java-basics/create-your-first-java-program-with-ease/">here</a>. We need to create the following classes: Car, Seat, Steeringwheel and a Main class to test the Java Objects. After creating all classes your project structure looks like the screenshot below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="337" height="335" src="https://jasta.io/wp-content/uploads/2024/03/JavaObjects.webp" alt="Java Objects Car example IntelliJ IDEA" class="wp-image-2864" srcset="https://jasta.io/wp-content/uploads/2024/03/JavaObjects.webp 337w, https://jasta.io/wp-content/uploads/2024/03/JavaObjects-300x298.webp 300w, https://jasta.io/wp-content/uploads/2024/03/JavaObjects-150x150.webp 150w, https://jasta.io/wp-content/uploads/2024/03/JavaObjects-148x148.webp 148w" sizes="auto, (max-width: 337px) 100vw, 337px" /></figure>
</div>


<p>First of all, we are adding code to the seat class. We are adding three variables to the class: material, weight and heating. Since we will probably know all of these when creating the seat we are setting all of them inside the constructor. Also, these attributes will not change, therefore they have the final keyword in front of the declaration so they can not be modified later on. To get the values of the variables we are also adding get methods.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public class Seat {

  private final String material;
  private final int weight;
  private final boolean heating;

  public Seat(String material, int weight, boolean heating) {
    this.material = material;
    this.weight = weight;
    this.heating = heating;
  }

  public String getMaterial() {
    return material;
  }

  public int getWeight() {
    return weight;
  }

  public boolean isHeating() {
    return heating;
  }
}</pre>



<p>The second class which will be implemented is the Steeringwheel class. For simplicity, we are just adding two variables: material and diameter. These will be known on creation and should not be changed later. Therefore the final keyword is added again and the values are assigned inside the constructor. In addition, of course, getter methods are added.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public class Steeringwheel {

  private final String material;
  private final int diameter;

  public Steeringwheel(String material, int diameter) {
    this.material = material;
    this.diameter = diameter;
  }

  public String getMaterial() {
    return material;
  }

  public int getDiameter() {
    return diameter;
  }
}</pre>



<p>Now that all Java Objects used for the car object are created, we can implement the car class. As previously described a car will have multiple seats therefore a list of seats, a String brand, a String model, a Steeringwheel object, a String plate and a String with the car&#8217;s color. The list type, the brand and the model shouldn&#8217;t be modified after initialization therefore they are declared final. Since the list type is already declared at the variable declaration only the brand and the model need to be set in the constructor. Every other attribute can be set via the corresponding set method. Of course getter methods are added as well.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import java.util.ArrayList;
import java.util.List;

public class Car {

  private final List&lt;Seat> seats = new ArrayList&lt;>();
  private final String brand;
  private final String model;
  private Steeringwheel steeringwheel;
  private String plate;
  private String color;

  public Car(String brand, String model) {
    this.brand = brand;
    this.model = model;
  }

  public List&lt;Seat> getSeats() {
    return seats;
  }

  public void addSeat(Seat seat) {
    seats.add(seat);
  }

  public String getBrand() {
    return brand;
  }

  public String getModel() {
    return model;
  }

  public Steeringwheel getSteeringwheel() {
    return steeringwheel;
  }

  public void setSteeringwheel(Steeringwheel steeringwheel) {
    this.steeringwheel = steeringwheel;
  }

  public String getPlate() {
    return plate;
  }

  public void setPlate(String plate) {
    this.plate = plate;
  }

  public String getColor() {
    return color;
  }

  public void setColor(String color) {
    this.color = color;
  }
}</pre>



<p>To test and understand how all this works, you can copy the code from below into your main class and execute it.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public class Main {

  public static void main(String[] args) {
    Car audiA4 = new Car("Audi", "A4");

    audiA4.setColor("green");

    Steeringwheel steeringwheel = new Steeringwheel("Leather", 38);
    audiA4.setSteeringwheel(steeringwheel);

    audiA4.addSeat(new Seat("Leather", 10, true));
    audiA4.addSeat(new Seat("Leather", 10, true));
    audiA4.addSeat(new Seat("Fabric", 8, false));
    audiA4.addSeat(new Seat("Fabric", 8, false));
    audiA4.addSeat(new Seat("Fabric", 8, false));

    audiA4.setPlate("ABCD1");

    System.out.println(
        "Car: " + audiA4.getBrand() + " " + audiA4.getModel() + " in " + audiA4.getColor());
    System.out.println(
        "Steeringwheel: " + audiA4.getSteeringwheel().getMaterial() + " steeringwheel which is "
            + audiA4.getSteeringwheel().getDiameter() + "cm big");

    int count = 1;
    String tempSeatOutput;
    for (Seat seat : audiA4.getSeats()) {
      tempSeatOutput =
          "Seat " + count + ": " + seat.getMaterial() + " seat which weights " + seat.getWeight()
              + "kg";

      if (seat.isHeating()) {
        tempSeatOutput += " and can heat up";
      } else {
        tempSeatOutput += " and cannot heat up";
      }

      System.out.println(tempSeatOutput);
      count++;
    }

    System.out.println("Plate: " + audiA4.getPlate());
  }
}</pre>



<p>The code above creates a new object with Car audiA4 = new Car(&#8220;Audi&#8221;, &#8220;A4&#8221;);. &#8216;Audi&#8217; and &#8216;A4&#8217; are the constructor arguments (brand and model). After creation, we are now using the setter methods of the car objects to set other variables. </p>



<p>The color is just set with a simple String argument. To set a Steeringwheel object we first have to create one. This is done like the Car object but now with Steeringwheel: Steeringwheel steeringwheel = new Steeringwheel(&#8220;Leather&#8221;, 38);. When creating the Steeringwheel Object the constructor arguments (material and diameter) are added. Now there are two separate objects. One is the Car and the other one is the Steeringwheel Object. To link the Steeringwheel object to the Car object we need to call the setSteeringwheel method of the car. The same process is now done with the seats but with anonymous objects.</p>



<p>Anonymous objects are used if you don&#8217;t need to access the object later on in the code. So you can type new Seat(&lt;material>, &lt;weight>, &lt;heating>) and add it immediately to the car with addSeat. This has two benefits. All this is done within one line and you don&#8217;t have to think about an object name. This can also be done with the Steeringwheel object since it will not be used directly later in the code.</p>



<p>After setting the plate every information about the car is printed out in the console. To do this the respective getter method is called to get the wanted String, Steeringwheel or Seat objects.</p>



<p>That&#8217;s the process of creating and using Java Objects. If you have any questions feel free to leave a comment.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/java-basics/mastering-java-objects-a-comprehensive-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Effortlessly Managing Your Projects with GitHub Desktop</title>
		<link>https://jasta.io/how-tos/managing-your-projects-with-github-desktop/</link>
					<comments>https://jasta.io/how-tos/managing-your-projects-with-github-desktop/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Sun, 17 Mar 2024 16:33:28 +0000</pubDate>
				<category><![CDATA[How-Tos]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[GitHub Desktop]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2818</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to easily enhance your project management with GitHub Desktop, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and set up GitHub Desktop.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#downloading-and-setting-up-git-hub-desktop">Downloading and Setting Up GitHub Desktop</a></li><li><a href="#managing-your-projects-with-git-hub-desktop">Managing Your Projects with GitHub Desktop</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="downloading-and-setting-up-git-hub-desktop">Downloading and Setting Up GitHub Desktop</h2>



<p>To start managing your projects with GitHub Desktop you first need to download the setup file. This can be done via the official GitHub Desktop Website. You can click <a href="https://desktop.github.com/" target="_blank" rel="noopener">here</a> to open it. After the Website has loaded click the Download button highlighted on the screenshot below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="620" src="https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-1024x620.webp" alt="Download GitHub Desktop" class="wp-image-2830" srcset="https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-1024x620.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-300x182.webp 300w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-768x465.webp 768w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-1536x930.webp 1536w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-512x310.webp 512w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-920x557.webp 920w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop-1600x968.webp 1600w, https://jasta.io/wp-content/uploads/2024/03/DownloadGithubDesktop.webp 1733w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>After downloading the setup executable file you can open and run it. When the setup is started up it looks like in the picture below. Now you have two options. The first is to log in with an already existing account which we will do in this tutorial. The second option is to create a new free account on GitHub. You can also create an account on the github.com website first and then follow the steps described below. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="957" height="656" src="https://jasta.io/wp-content/uploads/2024/03/InstallGithubDesktop.webp" alt="Set up GitHub Desktop" class="wp-image-2832" srcset="https://jasta.io/wp-content/uploads/2024/03/InstallGithubDesktop.webp 957w, https://jasta.io/wp-content/uploads/2024/03/InstallGithubDesktop-300x206.webp 300w, https://jasta.io/wp-content/uploads/2024/03/InstallGithubDesktop-768x526.webp 768w, https://jasta.io/wp-content/uploads/2024/03/InstallGithubDesktop-512x351.webp 512w, https://jasta.io/wp-content/uploads/2024/03/InstallGithubDesktop-920x631.webp 920w" sizes="auto, (max-width: 957px) 100vw, 957px" /></figure>
</div>


<p>After clicking on Sign in to GitHub.com you are redirected to the GitHub website where you have to authorize GitHub Desktop rights to your account. To do this press &#8216;Authorize desktop&#8217; on the right. If you don&#8217;t see the screen from below you have to log in to your account first.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="610" height="801" src="https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop.webp" alt="Authorize GitHub for GitHub Desktop" class="wp-image-2833" srcset="https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop.webp 610w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop-228x300.webp 228w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop-512x672.webp 512w" sizes="auto, (max-width: 610px) 100vw, 610px" /></figure>
</div>


<p>After authorization, your web browser will ask you for permission to open GitHub Desktop again. This message can vary from browser to browser. In Microsoft Edge, you need to click on Open. If you want to always open GitHub Desktop automatically in the future you can also check the checkbox above the buttons.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="504" height="160" src="https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop2.webp" alt="Open GitHub Desktop" class="wp-image-2834" srcset="https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop2.webp 504w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop2-300x95.webp 300w" sizes="auto, (max-width: 504px) 100vw, 504px" /></figure>
</div>


<p>After opening GitHub Desktop again your Git configuration will be displayed on your screen. There may be an auto-generated email address in the email field. You can change that back to your default GitHub email address by clicking the arrow next to it. When everything is configured you can hit Finish.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="954" height="651" src="https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop3.webp" alt="Configure Git" class="wp-image-2835" srcset="https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop3.webp 954w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop3-300x205.webp 300w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop3-768x524.webp 768w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop3-512x349.webp 512w, https://jasta.io/wp-content/uploads/2024/03/LoginGithubDesktop3-920x628.webp 920w" sizes="auto, (max-width: 954px) 100vw, 954px" /></figure>
</div>


<h2 class="wp-block-heading" id="managing-your-projects-with-git-hub-desktop">Managing Your Projects with GitHub Desktop</h2>



<p>To start managing your projects with GitHub Desktop you need to clone a repository. You can see your existing repositories on the left side of the screen. There you can select one and click on Clone &lt;YourRepositoryName>. If you don&#8217;t have a repository yet you can also try the options on the right side of the screen. With &#8216;Create a New Repository on your hard drive&#8230;&#8217; a completely new folder will be created and used as a repository. With the button below you can transform an existing folder to a repository.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="954" height="653" src="https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop.webp" alt="Clone a repository in GitHub Desktop" class="wp-image-2836" srcset="https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop.webp 954w, https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop-300x205.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop-768x526.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop-512x350.webp 512w, https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop-920x630.webp 920w" sizes="auto, (max-width: 954px) 100vw, 954px" /></figure>
</div>


<p>After pressing Clone, you will see another dialog popping up. There you can find the GitHub address of the repository and the location where you want to place it on your hard drive. Adjust it to your needs and confirm your choice with a final click on Clone.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="493" height="305" src="https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop2.webp" alt="Clone a repo with GitHub Desktop" class="wp-image-2837" srcset="https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop2.webp 493w, https://jasta.io/wp-content/uploads/2024/03/CloneRepositoryGithubDesktop2-300x186.webp 300w" sizes="auto, (max-width: 493px) 100vw, 493px" /></figure>
</div>


<p>You can start committing to the repo after the cloning process. To commit something to a GitHub you first need some changes. The best practice is to create or update the ReadMe.md file. After saving the file, GitHub Desktop automatically detects changes and will display them to you. You can see all the changes made in the currently selected file on the right. On the left side, you can see all modified files. There you can also deselect files that you don&#8217;t want to commit. On the bottom of the left side, you will see the field for the commit message, the description and the Commit button.</p>



<p>You can commit your changes to different branches which can be selected at the top of the screen. Since this is just the ReadMe file it will be committed to the main branch. After you have made sure that you have just selected the files you want to commit, selected the correct branch, entered a commit message and optionally added a description you can click Commit.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="956" height="656" src="https://jasta.io/wp-content/uploads/2024/03/CommitGithubDesktop.webp" alt="Commit changes with GitHub Desktop" class="wp-image-2838" srcset="https://jasta.io/wp-content/uploads/2024/03/CommitGithubDesktop.webp 956w, https://jasta.io/wp-content/uploads/2024/03/CommitGithubDesktop-300x206.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CommitGithubDesktop-768x527.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CommitGithubDesktop-512x351.webp 512w, https://jasta.io/wp-content/uploads/2024/03/CommitGithubDesktop-920x631.webp 920w" sizes="auto, (max-width: 956px) 100vw, 956px" /></figure>
</div>


<p>After pressing commit you have to push the changes to the repository. This can be done either with a click on the Push button in the blue box, with CTRL+P or a press Push at the top of the view. If you don&#8217;t see the Push origin at the top you can click on the arrow to switch modes. Now your changes are pushed to the repository.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="955" height="660" src="https://jasta.io/wp-content/uploads/2024/03/PushGithubDesktop.webp" alt="Push changes with GitHub Desktop" class="wp-image-2839" srcset="https://jasta.io/wp-content/uploads/2024/03/PushGithubDesktop.webp 955w, https://jasta.io/wp-content/uploads/2024/03/PushGithubDesktop-300x207.webp 300w, https://jasta.io/wp-content/uploads/2024/03/PushGithubDesktop-768x531.webp 768w, https://jasta.io/wp-content/uploads/2024/03/PushGithubDesktop-512x354.webp 512w, https://jasta.io/wp-content/uploads/2024/03/PushGithubDesktop-920x636.webp 920w" sizes="auto, (max-width: 955px) 100vw, 955px" /></figure>
</div>


<p>When there are multiple team members or you have made changes on the GitHub web app you want to have those changes locally as well. This is also done with a click on Pull in the blue box, CTRL+SHIFT+P or with the top menu. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="953" height="657" src="https://jasta.io/wp-content/uploads/2024/03/PullGithubDesktop.webp" alt="Pull changes with GitHub Desktop" class="wp-image-2840" srcset="https://jasta.io/wp-content/uploads/2024/03/PullGithubDesktop.webp 953w, https://jasta.io/wp-content/uploads/2024/03/PullGithubDesktop-300x207.webp 300w, https://jasta.io/wp-content/uploads/2024/03/PullGithubDesktop-768x529.webp 768w, https://jasta.io/wp-content/uploads/2024/03/PullGithubDesktop-512x353.webp 512w, https://jasta.io/wp-content/uploads/2024/03/PullGithubDesktop-920x634.webp 920w" sizes="auto, (max-width: 953px) 100vw, 953px" /></figure>
</div>


<p>To see the repository history in GitHub Desktop you can press History on the left side. You can see every change with the included files and the exact changes depending on the selected files. </p>



<p>With the top menu, you can switch between repositories and branches to see exactly where what changed. With these features, monitoring and managing your projects with GitHub Desktop can be done by everyone.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="958" height="652" src="https://jasta.io/wp-content/uploads/2024/03/HistoryGithubDesktop.webp" alt="Managing Your Projects with GitHub Desktop" class="wp-image-2841" srcset="https://jasta.io/wp-content/uploads/2024/03/HistoryGithubDesktop.webp 958w, https://jasta.io/wp-content/uploads/2024/03/HistoryGithubDesktop-300x204.webp 300w, https://jasta.io/wp-content/uploads/2024/03/HistoryGithubDesktop-768x523.webp 768w, https://jasta.io/wp-content/uploads/2024/03/HistoryGithubDesktop-512x348.webp 512w, https://jasta.io/wp-content/uploads/2024/03/HistoryGithubDesktop-920x626.webp 920w" sizes="auto, (max-width: 958px) 100vw, 958px" /></figure>
</div>


<p>Now you should be able to manage your <a href="https://jasta.io/java-basics/">Java</a>, <a href="https://jasta.io/mobile-apps/">Android</a> and many more projects easily. If you have any problems or questions feel free to leave a comment.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/how-tos/managing-your-projects-with-github-desktop/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Crafting Your First Android App with Java: A Beginner&#8217;s Guide to Success</title>
		<link>https://jasta.io/mobile-apps/crafting-your-first-android-app-with-java/</link>
					<comments>https://jasta.io/mobile-apps/crafting-your-first-android-app-with-java/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Sat, 16 Mar 2024 14:51:36 +0000</pubDate>
				<category><![CDATA[Mobile Apps]]></category>
		<category><![CDATA[Android Studio]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile-App]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2791</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to create your first Android app with Java, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and create an Android app with Java.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#creating-an-android-app-with-java-in-android-studio">Creating an Android App with Java in Android Studio</a></li><li><a href="#extending-the-source-code-of-your-app">Extending the Source Code of Your App</a></li><li><a href="#testing-your-first-android-app-with-java">Testing Your First Android App with Java</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="creating-an-android-app-with-java-in-android-studio">Creating an Android App with Java in Android Studio</h2>



<p>To start, you first need to click on the new project button to start configuring your Android app.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="775" height="632" src="https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject.webp" alt="Create a new project in Android Studio" class="wp-image-2799" srcset="https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject.webp 775w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject-300x245.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject-768x626.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject-512x418.webp 512w" sizes="auto, (max-width: 775px) 100vw, 775px" /></figure>
</div>


<p>On the first page, you need to select what activity you want to use for creating your app. Since we don&#8217;t want any pre-created buttons or menus in this app we are just using the Empty Views Activity. </p>



<p>FYI: An activity is one screen of an app. If you are for example creating an app with a login mechanism you would have the following activities:</p>



<ul class="wp-block-list">
<li>Login Activity</li>



<li>Registration Activity</li>



<li>Home Activity</li>
</ul>



<p>The app would probably start with the login activity. On this activity, you could now have two fields for email and password and two buttons. One for new users which would open the registration activity and one login button which would redirect the user to the home activity. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="890" height="644" src="https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject2.webp" alt="Empty Views Activity in Android Studio" class="wp-image-2800" srcset="https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject2.webp 890w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject2-300x217.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject2-768x556.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject2-512x370.webp 512w" sizes="auto, (max-width: 890px) 100vw, 890px" /></figure>
</div>


<p>After pressing next you will see the actual configuration screen of your project. There you can change various settings for your app. You can enter whatever you like regarding the name and the package name. This applies also to the save location. However, if you change the directory, no new folder will be created with the project name so the project gets generated exactly in the folder you choose. So don&#8217;t choose a parent folder without creating a subfolder.</p>



<p>For the language you should also choose whatever you know the best. For this tutorial, I am choosing Java. The next point is the minimum SDK. This means any device with an Android version below this version won&#8217;t be able to download and use this app. A good minimum SDK is API 24 which is already preselected. Below the drop-down menu, you can also see how many smartphones can use this app. The last configuration option is the build configuration language. You can choose between Kotlin and Groovy and since Kotlin is superior we are choosing it.</p>



<p>After every configuration option is set it should look similar to the screenshot below. If this is the case you can start the generating process of your Android app with Java by clicking Finish.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="897" height="646" src="https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject3.webp" alt="Project configuration in Android Studio" class="wp-image-2801" srcset="https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject3.webp 897w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject3-300x216.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject3-768x553.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CreateAndroidStudioProject3-512x369.webp 512w" sizes="auto, (max-width: 897px) 100vw, 897px" /></figure>
</div>


<p>After your project is generated you should locate two important files in the project explorer on the left of the screen. The MainActivity class contains all the programming logic for our activity. The activity_main.xml file contains the information on how your MainActivity will look like.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="448" height="416" src="https://jasta.io/wp-content/uploads/2024/03/AppExplorer.webp" alt="Project explorer inside Android Studio" class="wp-image-2803" srcset="https://jasta.io/wp-content/uploads/2024/03/AppExplorer.webp 448w, https://jasta.io/wp-content/uploads/2024/03/AppExplorer-300x279.webp 300w" sizes="auto, (max-width: 448px) 100vw, 448px" /></figure>
</div>


<p>When opening the activity_main.xml you will probably see a white screen with a Hello World! text since this is the default option. But there is also an option to see the code of the actual file side by side with the live preview of it which is mandatory for developing an app. To switch to this view click on the symbol in the top right corner highlighted in the screenshot below. You can also see another highlighted button. With that, you can switch from seeing a blueprint beneath the actual preview of the activity to just previewing the activity. For that, you have to switch to Design only.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="834" src="https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio-1024x834.webp" alt="See code and preview side by side in Android Studio" class="wp-image-2804" srcset="https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio-1024x834.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio-300x244.webp 300w, https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio-768x626.webp 768w, https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio-512x417.webp 512w, https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio-920x749.webp 920w, https://jasta.io/wp-content/uploads/2024/03/layoutPreviewSettingsAndroidStudio.webp 1295w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading" id="extending-the-source-code-of-your-app">Extending the Source Code of Your App</h2>



<p>Now that you know the basics we are extending the source code of your Android app with Java a bit so there will be a Button that can be pressed which increases a counter that is displayed in a TextView. For this, we are giving the already existing TextView in the activity_main.xml an ID. An ID is needed so we can access the TextView via the logic inside the MainActivity Java class. To add an ID you need to add the line below inside the TextView tag.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">android:id="@+id/counterLabel"</pre>



<p>After adding this line we are also adding a Button to the activity with this code:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">    &lt;Button
        android:id="@+id/countUpButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Count up"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/counterLabel" /></pre>



<p>Now our activity_main.xml is done and should look like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?xml version="1.0" encoding="utf-8"?>
&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    &lt;TextView
        android:id="@+id/counterLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    &lt;Button
        android:id="@+id/countUpButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Count up"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/counterLabel" />

&lt;/androidx.constraintlayout.widget.ConstraintLayout></pre>



<p>The user interface is now done. There is a Button and a TextView. Now we need to access these two components inside the MainActivity.java and work with them.<br>First of all, we are adding 3 variables to the class.</p>



<ul class="wp-block-list">
<li>private TextView counterLabel; This will be set to our TextView</li>



<li>private Button counterButton; This will be set to our Button</li>



<li>private int currentCount = 0; This will work as our counter variable</li>
</ul>



<p>Then we initialize the TextView and Button variables. This can be done in the onCreate method since this method is only once called at the very start of the activity. To get different components of your XML files you call findViewById(R.id.&lt;IDInsideXMLFile&gt;). So the assignments will look like this.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">counterLabel = findViewById(R.id.counterLabel);
counterButton = findViewById(R.id.countUpButton);</pre>



<p>The next step is to set the text of the counter label to 0. For setting an initial value there are always two options. The first one is to set it directly inside the activity_main.xml file with the android:text attribute or you can do it via code like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">counterLabel.setText(String.valueOf(currentCount));</pre>



<p>Last, we need to add an onClickListener with which we can override the onClick method to increase our counter and set the new value to our TextView. To do this you can either use a lambda expression or not. That depends entirely on what you prefer to use. You can see the difference below:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">counterButton.setOnClickListener(v -> {
    currentCount++;
    counterLabel.setText(String.valueOf(currentCount));
});

counterButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        currentCount++;
        counterLabel.setText(String.valueOf(currentCount));
    }
});</pre>



<p>Finally, your finished MainActivity class will look like this:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package com.example.myfirstandroidapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private TextView counterLabel;
    private Button counterButton;
    private int currentCount = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        counterLabel = findViewById(R.id.counterLabel);
        counterButton = findViewById(R.id.countUpButton);

        counterLabel.setText(String.valueOf(currentCount));

        counterButton.setOnClickListener((v) -> {
            currentCount++;
            counterLabel.setText(String.valueOf(currentCount));
        });
    }
}</pre>



<p>Always call findViewById after super.onCreate(savedInstanceState); and setContentView(R.layout.activity_main);. Otherwise, it will not work.</p>



<h2 class="wp-block-heading" id="testing-your-first-android-app-with-java">Testing Your First Android App with Java</h2>



<p>To test your newly created Android app with Java you have two options. <br>The first one is to use your real mobile phone. You can either connect it via cable or connect via Wi-Fi. To do this you first need to enable the respective debugging mode on your smartphone in the developer settings. This can vary from brand to brand so the best thing is to Google how to do it on your device. After enabling the mode you can connect your device via cable and the smartphone will automatically show up on the devices list, or you use &#8216;Pair Devices Using Wi-Fi&#8217; from the options in the screenshot below and follow the steps displayed.</p>



<p>The second option to test your Android app with Java is, to use a virtual device. The advantage of a virtual device is, that you can have multiple. So you can test your app on devices with different sizes and Android versions. Furthermore, you can test device categories that you may not even own, like a smartwatch. To learn how to add a virtual device you can click <a href="https://jasta.io/how-tos/add-a-powerful-virtual-device-in-android-studio/">here</a>.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="382" height="224" src="https://jasta.io/wp-content/uploads/2024/03/AndroidStudioTestApp.webp" alt="Available devices in Android Studio" class="wp-image-2796" srcset="https://jasta.io/wp-content/uploads/2024/03/AndroidStudioTestApp.webp 382w, https://jasta.io/wp-content/uploads/2024/03/AndroidStudioTestApp-300x176.webp 300w" sizes="auto, (max-width: 382px) 100vw, 382px" /></figure>
</div>


<p>After you have added/selected the correct device you can now click on the play button next to the drop-down list, which is also highlighted in the screenshot below to start your app.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="578" src="https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-1024x578.webp" alt="Run you app in Android Studio" class="wp-image-2807" srcset="https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-1024x578.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-300x169.webp 300w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-768x433.webp 768w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-1536x867.webp 1536w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-2048x1156.webp 2048w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-512x289.webp 512w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-920x519.webp 920w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-1600x903.webp 1600w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1-1920x1084.webp 1920w, https://jasta.io/wp-content/uploads/2024/03/StartAndroidApp-1.webp 2151w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>After clicking the button the app will be built. When the build process is finished the virtual device will start and launch your app. If you use your personal device the app will also launch itself. After the application is started on your device it should look like the preview from the activity_main.xml file. To test the logic we implemented you can click on the counter button. You will then see the counter getting increased with each click. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="669" height="744" src="https://jasta.io/wp-content/uploads/2024/03/FinishedApp-1.webp" alt="Android app with Java in Android Studio" class="wp-image-2808" srcset="https://jasta.io/wp-content/uploads/2024/03/FinishedApp-1.webp 669w, https://jasta.io/wp-content/uploads/2024/03/FinishedApp-1-270x300.webp 270w, https://jasta.io/wp-content/uploads/2024/03/FinishedApp-1-512x569.webp 512w" sizes="auto, (max-width: 669px) 100vw, 669px" /></figure>
</div>


<p>This was the process of creating your first Android app with Java in Android Studio. If you have any problems or questions feel free to comment below. To read more about creating an app in Android Studio you can visit the <a href="https://developer.android.com/codelabs/build-your-first-android-app#0" target="_blank" rel="noopener">documentation of Google</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/mobile-apps/crafting-your-first-android-app-with-java/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Add a Powerful Virtual Device in Android Studio</title>
		<link>https://jasta.io/how-tos/add-a-powerful-virtual-device-in-android-studio/</link>
					<comments>https://jasta.io/how-tos/add-a-powerful-virtual-device-in-android-studio/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Fri, 15 Mar 2024 19:15:03 +0000</pubDate>
				<category><![CDATA[How-Tos]]></category>
		<category><![CDATA[Android Studio]]></category>
		<category><![CDATA[Device Manager]]></category>
		<category><![CDATA[Virtual Devices]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2771</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to add a powerful virtual device in Android Studio, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and add a powerful virtual device in Android Studio.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#why-you-should-have-one-or-more-virtual-devices">Why You Should Have One or More Virtual Devices</a></li><li><a href="#add-a-powerful-virtual-device-in-android-studio">Add a Powerful Virtual Device in Android Studio</a></li><li><a href="#problem-black-circle-on-the-screen-in-addition-to-the-camera">Problem: Black Circle on the Screen in Addition to the Camera</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="why-you-should-have-one-or-more-virtual-devices">Why You Should Have One or More Virtual Devices</h2>



<p>After developing mobile applications you will ask yourself how to test your app. There are two options: The first option is, to load your program on your smartphone. The benefits are clear. Once uploaded on your phone you can show it to friends and family members but there are also downsides. The phone must be either connected via cable or wirelessly. Additionally, debugging has to be enabled in the developer settings. Furthermore, it always has to be nearby and the uploading process often takes quite a long time.</p>



<p>With a virtual device, you don&#8217;t need to have your phone always with you to test your mobile applications. You can press &#8216;Run&#8217; inside Android Studio and a virtual smartphone will be powered up where your app gets deployed. Also with the virtual device, you can simulate different things like a bad internet connection.</p>



<p>Another big advantage is, that you can have multiple virtual devices with different screen sizes and Android versions, which is extremely useful for developing apps, which have to work for older phones and should also look good on foldable phones or phones with rather small displays.</p>



<h2 class="wp-block-heading" id="add-a-powerful-virtual-device-in-android-studio">Add a Powerful Virtual Device in Android Studio</h2>



<p>To add a powerful virtual device in Android Studio the first thing you need to do is to check if Hyper-V is enabled. To learn how to enable it, you can click <a href="https://jasta.io/how-tos/enable-hyper-v-on-windows-11/">here</a>. After you have enabled it, you need to open the device manager in Android Studio. This can be done with the menu on the very right in Android Studio. There you have to click on the icon with a smartphone and the android logo. You can see the location in the screenshot below. After opening it, you have to click on the plus symbol to add a new powerful virtual device in Android Studio.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-1024x576.webp" alt="Add a powerful virtual device in Android Studio" class="wp-image-2774" srcset="https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-1024x576.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-300x169.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-768x432.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-1536x864.webp 1536w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-2048x1151.webp 2048w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-512x288.webp 512w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-920x517.webp 920w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-1600x900.webp 1600w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1-1920x1079.webp 1920w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice1.webp 2154w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>After clicking on the plus icon, a new dialog will be displayed on your screen. Now the real process to add a powerful virtual device in Android Studio begins. First of all, you have to decide which device you want to create. You can choose from different categories like phones, tablets, watches, or even TVs. In this tutorial, we are using the Google Pixel 8 since the size is rather common. After choosing the device you can confirm your selection with a click on Next.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="694" src="https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2-1024x694.webp" alt="Choose a virtual device size in Android Studio device manager" class="wp-image-2775" srcset="https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2-1024x694.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2-300x203.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2-768x521.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2-512x347.webp 512w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2-920x624.webp 920w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDevice2.webp 1099w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>In the next dialog window, you can choose your desired Android version for your new virtual device in Android Studio. If you have already downloaded the desired version, you can select it and click on next. Otherwise, you have to click on the small download icon next to the Android version name. In this case, I am choosing the newest version, 14.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="699" src="https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage-1024x699.webp" alt="Download Android 14 SDK" class="wp-image-2776" srcset="https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage-1024x699.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage-300x205.webp 300w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage-768x524.webp 768w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage-512x349.webp 512w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage-920x628.webp 920w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage.webp 1096w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>After pressing on download another window will appear where you must accept the license agreement. Just select Accept and press Next to start downloading the SDK.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="900" height="647" src="https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage2.webp" alt="Accept license agreement in Android Studio" class="wp-image-2777" srcset="https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage2.webp 900w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage2-300x216.webp 300w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage2-768x552.webp 768w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage2-512x368.webp 512w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure>
</div>


<p>The download will take some time. After it is finished you can press the Finish button in the bottom right corner of the download dialog.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="897" height="645" src="https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage3.webp" alt="Download SDK in Android Studio" class="wp-image-2778" srcset="https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage3.webp 897w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage3-300x216.webp 300w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage3-768x552.webp 768w, https://jasta.io/wp-content/uploads/2024/03/DownloadSystemImage3-512x368.webp 512w" sizes="auto, (max-width: 897px) 100vw, 897px" /></figure>
</div>


<p>After clicking on Finish you will be back at the window where you can choose the desired Android version. You can now select the downloaded version and confirm the selection by pressing Next on the bottom.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="694" src="https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload-1024x694.webp" alt="Choose the android version in Android Studio" class="wp-image-2779" srcset="https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload-1024x694.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload-300x203.webp 300w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload-768x520.webp 768w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload-512x347.webp 512w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload-920x623.webp 920w, https://jasta.io/wp-content/uploads/2024/03/CreateVirtualDeviceAfterDownload.webp 1100w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>After clicking Next you will see the last dialog to create a virtual device in Android Studio. There you will see a quick overview of your selections and you can also give the device a name. I would recommend that you include the API version (Android version) in the name, so you quickly know what version the device is running on. After you have checked your previous selections and named your device you can finish the process to add a virtual device in Android Studio with a click on the Finish button.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="699" src="https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice-1024x699.webp" alt="Create a virtual device in Android Studio" class="wp-image-2780" srcset="https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice-1024x699.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice-300x205.webp 300w, https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice-768x524.webp 768w, https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice-512x349.webp 512w, https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice-920x628.webp 920w, https://jasta.io/wp-content/uploads/2024/03/FinishVirtualDevice.webp 1096w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Now your device will show up in the device overview of the device manager. You can start the virtual smartphone directly by launching your app with the play icon on the top or you can start the device without starting your mobile application via the play button next to your device inside the device manager.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="893" height="363" src="https://jasta.io/wp-content/uploads/2024/03/StartNewVirtualDevice.webp" alt="Start a virtual device in Android Studio" class="wp-image-2781" srcset="https://jasta.io/wp-content/uploads/2024/03/StartNewVirtualDevice.webp 893w, https://jasta.io/wp-content/uploads/2024/03/StartNewVirtualDevice-300x122.webp 300w, https://jasta.io/wp-content/uploads/2024/03/StartNewVirtualDevice-768x312.webp 768w, https://jasta.io/wp-content/uploads/2024/03/StartNewVirtualDevice-512x208.webp 512w" sizes="auto, (max-width: 893px) 100vw, 893px" /></figure>
</div>


<h2 class="wp-block-heading" id="problem-black-circle-on-the-screen-in-addition-to-the-camera">Problem: Black Circle on the Screen in Addition to the Camera</h2>



<p>Sometimes there might be a problem after you&#8217;ve added a powerful virtual device to Android Studio &#8211; a black circle is displayed on the screen in addition to the camera punch hole. This is because a display cutout is activated in the developer options of the device. To deactivate it you first have to activate the developer options. You can do this by opening the settings on the smartphone, then clicking on &#8216;About phone&#8217; and scrolling down to &#8216;Build number&#8217;. You have to click on Build number 7 times to enable the developer options. After clicking on it that many times you will see a message on the screen that the developer options are now enabled.</p>



<p>After the activation, you have to go back to the start of the settings. Now scroll down to &#8216;System&#8217; and open the &#8216;Developer options&#8217;. You now have to search for &#8216;Display cutout&#8217;. The setting is located approximately two-thirds of the way up the menu. After you have found it you can click on it and select &#8216;Device default&#8217; so only the normal camera punch hole is visible.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="320" height="666" src="https://jasta.io/wp-content/uploads/2024/03/BlackDot.webp" alt="Remove black circle of virtual device in android studio" class="wp-image-2782" srcset="https://jasta.io/wp-content/uploads/2024/03/BlackDot.webp 320w, https://jasta.io/wp-content/uploads/2024/03/BlackDot-144x300.webp 144w" sizes="auto, (max-width: 320px) 100vw, 320px" /></figure>
</div>


<p>Now everything should be working without any problems. If you have any troubles or questions feel free to leave a comment or visit the <a href="https://developer.android.com/studio/run/managing-avds" target="_blank" rel="noopener">official documentation</a> of Google.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/how-tos/add-a-powerful-virtual-device-in-android-studio/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Improve Your Code and Make It More Readable with Google Code Style in 5 Simple Steps</title>
		<link>https://jasta.io/how-tos/improve-code-with-google-code-style-in-intellij/</link>
					<comments>https://jasta.io/how-tos/improve-code-with-google-code-style-in-intellij/#respond</comments>
		
		<dc:creator><![CDATA[Jakob]]></dc:creator>
		<pubDate>Mon, 11 Mar 2024 18:35:18 +0000</pubDate>
				<category><![CDATA[How-Tos]]></category>
		<category><![CDATA[Code Style]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<guid isPermaLink="false">https://jasta.io/?p=2748</guid>

					<description><![CDATA[Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Hello tech enthusiasts! Welcome back to jasta, your go-to destination for all things tech. Today, we’re diving into how to make your code cleaner and more readable with Google Code Style in 5 simple steps, providing a step-by-step guide to help you accomplish this on your computer. Whether you’re a seasoned tech guru or just starting your digital journey, our straightforward instructions will make the process a breeze. Let’s jump in and enable Google Code Style in IntelliJ IDEA.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#why-you-should-format-your-code">Why You Should Format Your Code</a></li><li><a href="#download-the-official-google-code-style">Download the Official Google Code Style</a></li><li><a href="#add-google-code-style-to-intelli-j-idea">Add Google Code Style to IntelliJ IDEA</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="why-you-should-format-your-code">Why You Should Format Your Code</h2>



<p>Formatting your code is like organizing your room – it makes everything easier to find and understand. Clean, well-formatted code is crucial for readability and maintainability, especially as projects grow. It helps you and others comprehend the logic and structure effortlessly. Consistent indentation, clear naming conventions, and proper spacing enhance code clarity, reducing errors and debugging time. Formatted code is also more professional, fostering collaboration and making it easier for others to contribute or review your work. </p>



<p>Ultimately, investing time in formatting your code pays off in improved efficiency, better collaboration, and smoother project maintenance, creating a solid foundation for your programming journey.</p>



<h2 class="wp-block-heading" id="download-the-official-google-code-style">Download the Official Google Code Style</h2>



<p>To now add Google Code Style to your programming environment (IntelliJ IDEA) and be able to format your code quickly, you first have to download the necessary file. The file you need is a simple XML file that can be downloaded from a GitHub repository. You can find the correct repository <a href="https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml" target="_blank" rel="noopener">here</a>.</p>



<p>The link provided above will directly open the needed file. To download it the file, you have to click on the download symbol in the top right corner. You can also see it highlighted in the screenshot below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="600" src="https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-1024x600.webp" alt="Download Google Code Style" class="wp-image-2749" srcset="https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-1024x600.webp 1024w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-300x176.webp 300w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-768x450.webp 768w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-1536x900.webp 1536w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-512x300.webp 512w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-920x539.webp 920w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle-1600x938.webp 1600w, https://jasta.io/wp-content/uploads/2024/03/DownloadGoogleCodeStyle.webp 1878w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>If you don&#8217;t want to download the file from GitHub, you can also copy the XML content from below and save it inside a new file. Make sure that you save it as a XML file, otherwise you won&#8217;t be able to use it inside IntelliJ IDEA.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;code_scheme name="GoogleStyle">
  &lt;option name="OTHER_INDENT_OPTIONS">
    &lt;value>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
      &lt;option name="USE_TAB_CHARACTER" value="false" />
      &lt;option name="SMART_TABS" value="false" />
      &lt;option name="LABEL_INDENT_SIZE" value="0" />
      &lt;option name="LABEL_INDENT_ABSOLUTE" value="false" />
      &lt;option name="USE_RELATIVE_INDENTS" value="false" />
    &lt;/value>
  &lt;/option>
  &lt;option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
  &lt;option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
  &lt;option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
  &lt;option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
    &lt;value />
  &lt;/option>
  &lt;option name="IMPORT_LAYOUT_TABLE">
    &lt;value>
      &lt;package name="" withSubpackages="true" static="true" />
      &lt;emptyLine />
      &lt;package name="" withSubpackages="true" static="false" />
    &lt;/value>
  &lt;/option>
  &lt;option name="RIGHT_MARGIN" value="100" />
  &lt;option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
  &lt;option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
  &lt;option name="JD_P_AT_EMPTY_LINES" value="false" />
  &lt;option name="JD_KEEP_EMPTY_PARAMETER" value="false" />
  &lt;option name="JD_KEEP_EMPTY_EXCEPTION" value="false" />
  &lt;option name="JD_KEEP_EMPTY_RETURN" value="false" />
  &lt;option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
  &lt;option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
  &lt;option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
  &lt;option name="BLANK_LINES_AFTER_CLASS_HEADER" value="0" />
  &lt;option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
  &lt;option name="ALIGN_MULTILINE_FOR" value="false" />
  &lt;option name="CALL_PARAMETERS_WRAP" value="1" />
  &lt;option name="METHOD_PARAMETERS_WRAP" value="1" />
  &lt;option name="EXTENDS_LIST_WRAP" value="1" />
  &lt;option name="THROWS_KEYWORD_WRAP" value="1" />
  &lt;option name="METHOD_CALL_CHAIN_WRAP" value="1" />
  &lt;option name="BINARY_OPERATION_WRAP" value="1" />
  &lt;option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
  &lt;option name="TERNARY_OPERATION_WRAP" value="1" />
  &lt;option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
  &lt;option name="FOR_STATEMENT_WRAP" value="1" />
  &lt;option name="ARRAY_INITIALIZER_WRAP" value="1" />
  &lt;option name="WRAP_COMMENTS" value="true" />
  &lt;option name="IF_BRACE_FORCE" value="3" />
  &lt;option name="DOWHILE_BRACE_FORCE" value="3" />
  &lt;option name="WHILE_BRACE_FORCE" value="3" />
  &lt;option name="FOR_BRACE_FORCE" value="3" />
  &lt;option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
  &lt;AndroidXmlCodeStyleSettings>
    &lt;option name="USE_CUSTOM_SETTINGS" value="true" />
    &lt;option name="LAYOUT_SETTINGS">
      &lt;value>
        &lt;option name="INSERT_BLANK_LINE_BEFORE_TAG" value="false" />
      &lt;/value>
    &lt;/option>
  &lt;/AndroidXmlCodeStyleSettings>
  &lt;JSCodeStyleSettings>
    &lt;option name="INDENT_CHAINED_CALLS" value="false" />
  &lt;/JSCodeStyleSettings>
  &lt;Python>
    &lt;option name="USE_CONTINUATION_INDENT_FOR_ARGUMENTS" value="true" />
  &lt;/Python>
  &lt;TypeScriptCodeStyleSettings>
    &lt;option name="INDENT_CHAINED_CALLS" value="false" />
  &lt;/TypeScriptCodeStyleSettings>
  &lt;XML>
    &lt;option name="XML_ALIGN_ATTRIBUTES" value="false" />
    &lt;option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
  &lt;/XML>
  &lt;codeStyleSettings language="CSS">
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="ECMA Script Level 4">
    &lt;option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    &lt;option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    &lt;option name="ALIGN_MULTILINE_FOR" value="false" />
    &lt;option name="CALL_PARAMETERS_WRAP" value="1" />
    &lt;option name="METHOD_PARAMETERS_WRAP" value="1" />
    &lt;option name="EXTENDS_LIST_WRAP" value="1" />
    &lt;option name="BINARY_OPERATION_WRAP" value="1" />
    &lt;option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
    &lt;option name="TERNARY_OPERATION_WRAP" value="1" />
    &lt;option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
    &lt;option name="FOR_STATEMENT_WRAP" value="1" />
    &lt;option name="ARRAY_INITIALIZER_WRAP" value="1" />
    &lt;option name="IF_BRACE_FORCE" value="3" />
    &lt;option name="DOWHILE_BRACE_FORCE" value="3" />
    &lt;option name="WHILE_BRACE_FORCE" value="3" />
    &lt;option name="FOR_BRACE_FORCE" value="3" />
    &lt;option name="PARENT_SETTINGS_INSTALLED" value="true" />
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="HTML">
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="JAVA">
    &lt;option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
    &lt;option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    &lt;option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
    &lt;option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    &lt;option name="ALIGN_MULTILINE_RESOURCES" value="false" />
    &lt;option name="ALIGN_MULTILINE_FOR" value="false" />
    &lt;option name="CALL_PARAMETERS_WRAP" value="1" />
    &lt;option name="METHOD_PARAMETERS_WRAP" value="1" />
    &lt;option name="EXTENDS_LIST_WRAP" value="1" />
    &lt;option name="THROWS_KEYWORD_WRAP" value="1" />
    &lt;option name="METHOD_CALL_CHAIN_WRAP" value="1" />
    &lt;option name="BINARY_OPERATION_WRAP" value="1" />
    &lt;option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
    &lt;option name="TERNARY_OPERATION_WRAP" value="1" />
    &lt;option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
    &lt;option name="FOR_STATEMENT_WRAP" value="1" />
    &lt;option name="ARRAY_INITIALIZER_WRAP" value="1" />
    &lt;option name="WRAP_COMMENTS" value="true" />
    &lt;option name="IF_BRACE_FORCE" value="3" />
    &lt;option name="DOWHILE_BRACE_FORCE" value="3" />
    &lt;option name="WHILE_BRACE_FORCE" value="3" />
    &lt;option name="FOR_BRACE_FORCE" value="3" />
    &lt;option name="PARENT_SETTINGS_INSTALLED" value="true" />
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="JSON">
    &lt;indentOptions>
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="JavaScript">
    &lt;option name="RIGHT_MARGIN" value="80" />
    &lt;option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    &lt;option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    &lt;option name="ALIGN_MULTILINE_FOR" value="false" />
    &lt;option name="CALL_PARAMETERS_WRAP" value="1" />
    &lt;option name="METHOD_PARAMETERS_WRAP" value="1" />
    &lt;option name="BINARY_OPERATION_WRAP" value="1" />
    &lt;option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
    &lt;option name="TERNARY_OPERATION_WRAP" value="1" />
    &lt;option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
    &lt;option name="FOR_STATEMENT_WRAP" value="1" />
    &lt;option name="ARRAY_INITIALIZER_WRAP" value="1" />
    &lt;option name="IF_BRACE_FORCE" value="3" />
    &lt;option name="DOWHILE_BRACE_FORCE" value="3" />
    &lt;option name="WHILE_BRACE_FORCE" value="3" />
    &lt;option name="FOR_BRACE_FORCE" value="3" />
    &lt;option name="PARENT_SETTINGS_INSTALLED" value="true" />
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="PROTO">
    &lt;option name="RIGHT_MARGIN" value="80" />
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="2" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="protobuf">
    &lt;option name="RIGHT_MARGIN" value="80" />
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="2" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="Python">
    &lt;option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    &lt;option name="RIGHT_MARGIN" value="80" />
    &lt;option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    &lt;option name="PARENT_SETTINGS_INSTALLED" value="true" />
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="SASS">
    &lt;indentOptions>
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="SCSS">
    &lt;indentOptions>
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="TypeScript">
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
  &lt;codeStyleSettings language="XML">
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="2" />
      &lt;option name="TAB_SIZE" value="2" />
    &lt;/indentOptions>
    &lt;arrangement>
      &lt;rules>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>xmlns:android&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>^$&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>xmlns:.*&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>^$&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:id&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>style&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>^$&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>^$&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:.*Style&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_width&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_height&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_weight&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_margin&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_marginTop&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_marginBottom&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_marginStart&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_marginEnd&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_marginLeft&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_marginRight&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:layout_.*&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:padding&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:paddingTop&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:paddingBottom&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:paddingStart&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:paddingEnd&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:paddingLeft&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*:paddingRight&lt;/NAME>
                &lt;XML_ATTRIBUTE />
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*&lt;/NAME>
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res/android&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*&lt;/NAME>
                &lt;XML_NAMESPACE>http://schemas.android.com/apk/res-auto&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*&lt;/NAME>
                &lt;XML_NAMESPACE>http://schemas.android.com/tools&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
        &lt;section>
          &lt;rule>
            &lt;match>
              &lt;AND>
                &lt;NAME>.*&lt;/NAME>
                &lt;XML_NAMESPACE>.*&lt;/XML_NAMESPACE>
              &lt;/AND>
            &lt;/match>
            &lt;order>BY_NAME&lt;/order>
          &lt;/rule>
        &lt;/section>
      &lt;/rules>
    &lt;/arrangement>
  &lt;/codeStyleSettings>
  &lt;Objective-C>
    &lt;option name="INDENT_NAMESPACE_MEMBERS" value="0" />
    &lt;option name="INDENT_C_STRUCT_MEMBERS" value="2" />
    &lt;option name="INDENT_CLASS_MEMBERS" value="2" />
    &lt;option name="INDENT_VISIBILITY_KEYWORDS" value="1" />
    &lt;option name="INDENT_INSIDE_CODE_BLOCK" value="2" />
    &lt;option name="KEEP_STRUCTURES_IN_ONE_LINE" value="true" />
    &lt;option name="FUNCTION_PARAMETERS_WRAP" value="5" />
    &lt;option name="FUNCTION_CALL_ARGUMENTS_WRAP" value="5" />
    &lt;option name="TEMPLATE_CALL_ARGUMENTS_WRAP" value="5" />
    &lt;option name="TEMPLATE_CALL_ARGUMENTS_ALIGN_MULTILINE" value="true" />
    &lt;option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
    &lt;option name="SPACE_BEFORE_SUPERCLASS_COLON" value="false" />
  &lt;/Objective-C>
  &lt;Objective-C-extensions>
    &lt;option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
    &lt;option name="RELEASE_STYLE" value="IVAR" />
    &lt;option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
    &lt;file>
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
    &lt;/file>
    &lt;class>
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
      &lt;option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
    &lt;/class>
    &lt;extensions>
      &lt;pair source="cc" header="h" />
      &lt;pair source="c" header="h" />
    &lt;/extensions>
  &lt;/Objective-C-extensions>
  &lt;codeStyleSettings language="ObjectiveC">
    &lt;option name="RIGHT_MARGIN" value="80" />
    &lt;option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
    &lt;option name="BLANK_LINES_BEFORE_IMPORTS" value="0" />
    &lt;option name="BLANK_LINES_AFTER_IMPORTS" value="0" />
    &lt;option name="BLANK_LINES_AROUND_CLASS" value="0" />
    &lt;option name="BLANK_LINES_AROUND_METHOD" value="0" />
    &lt;option name="BLANK_LINES_AROUND_METHOD_IN_INTERFACE" value="0" />
    &lt;option name="ALIGN_MULTILINE_BINARY_OPERATION" value="false" />
    &lt;option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
    &lt;option name="FOR_STATEMENT_WRAP" value="1" />
    &lt;option name="ASSIGNMENT_WRAP" value="1" />
    &lt;indentOptions>
      &lt;option name="INDENT_SIZE" value="2" />
      &lt;option name="CONTINUATION_INDENT_SIZE" value="4" />
    &lt;/indentOptions>
  &lt;/codeStyleSettings>
&lt;/code_scheme></pre>



<h2 class="wp-block-heading" id="add-google-code-style-to-intelli-j-idea">Add Google Code Style to IntelliJ IDEA</h2>



<p>After downloading the file or creating one with the provided content above, you can now start IntelliJ IDEA. After starting you first have to select File on the top menu and click on Settings. Alternatively you can press CTRL+ALT+S to open the settings of IntelliJ. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="355" height="559" src="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle.webp" alt="IntelliJ open settings" class="wp-image-2752" srcset="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle.webp 355w, https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle-191x300.webp 191w" sizes="auto, (max-width: 355px) 100vw, 355px" /></figure>
</div>


<p>After the settings windows is opened, you have to open the Editor entry on the left-hand side of the window and then find Code Style and click on it. At the top of the window, you should now see a Scheme label with a drop-down menu and a settings wheel next to it. To now import your XML file you have to click on the settings wheel, select the last menu entry, Import Scheme, and last but not least click on IntelliJ IDEA code style XML.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="980" height="731" src="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle2.webp" alt="IntelliJ import code style xml" class="wp-image-2755" srcset="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle2.webp 980w, https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle2-300x224.webp 300w, https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle2-768x573.webp 768w, https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle2-512x382.webp 512w, https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle2-920x686.webp 920w" sizes="auto, (max-width: 980px) 100vw, 980px" /></figure>
</div>


<p>Now a popup will be displayed to you, where you have to select your Google Code Style XML file. So find it on the presented explorer and click on it once. To confirm your choice you have to press OK on the bottom of the dialog.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="454" height="518" src="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle3.webp" alt="Select Google Code Style" class="wp-image-2756" srcset="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle3.webp 454w, https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle3-263x300.webp 263w" sizes="auto, (max-width: 454px) 100vw, 454px" /></figure>
</div>


<p>After confirming your choice, you have now the option to give your code style a name. Just give it a name you like and you remember that this is the Google Code Style. In this example, I named it GoogleStyle.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="241" height="228" src="https://jasta.io/wp-content/uploads/2024/03/GoogleCodeStyle4.webp" alt="Name your newly imported IntelliJ code style" class="wp-image-2757"/></figure>
</div>


<p>Lastly, you may need to select the just-created style as your default IntelliJ IDEA code style. To do so you have to select the new entry from the drop-down menu next to the settings wheel where you have just imported the settings. After doing so you can click on Apply or OK to apply the newly made settings.</p>



<p>To now format your code you have to select the area where you want to apply the Google Code Style or select the whole class with CTRL+A and then format it with CTRL+ALT+L. Now your code is formatted according to the code style inside the imported XML file.  </p>
]]></content:encoded>
					
					<wfw:commentRss>https://jasta.io/how-tos/improve-code-with-google-code-style-in-intellij/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
