<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>CodeProject Latest postings for Java</title>
    <link>https://www.codeproject.com</link>
    <description>Latest postings for Java from CodeProject</description>
    <language>en-us</language>
    <image>
      <title>CodeProject Latest postings for Java</title>
      <url>https://www.codeproject.com/App_Themes/Std/Img/logo100x30.gif</url>
      <link>https://www.codeproject.com</link>
      <width>100</width>
      <height>30</height>
      <description>CodeProject</description>
    </image>
    <copyright>Copyright  CodeProject, 1999-2024</copyright>
    <webMaster>Webmaster@codeproject.com (Webmaster)</webMaster>
    <lastBuildDate>Mon, 25 Mar 2024 06:18:00 GMT</lastBuildDate>
    <ttl>20</ttl>
    <generator>C# Hand-coded goodness</generator>
    <item>
      <title>Forum Guidelines - PLEASE READ</title>
      <description>When posting your question please:&lt;ol&gt;&lt;li&gt;&lt;b&gt;Choose the correct forum for your message&lt;/b&gt;. Posting a VB.NET question in the C++ forum will end in tears.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;&lt;b&gt;Be specific!&lt;/b&gt; Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Keep the subject line brief, but descriptive. eg "File Serialization problem"&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;If you are posting source code with your question, place it inside &amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt; tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums. &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;No advertising or soliciting.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
When answering a question please:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Read the question carefully&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Understand that English isn't everyone's first language so be lenient of bad spelling and grammar&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. &lt;b&gt;Insults are not welcome&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;If the question is inappropriate then click the 'vote to remove message' button&lt;br /&gt;
&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid. &lt;br /&gt;
&lt;br /&gt;
&lt;div class="ForumSig"&gt;cheers,&lt;br /&gt;
Chris Maunder&lt;br /&gt;
&lt;br /&gt;
The Code Project Co-fou&lt;/div&gt;</description>
      <author>Chris Maunder</author>
      <link>https://www.codeproject.com/Messages/3137511/Forum-Guidelines-PLEASE-READ</link>
      <pubDate>Tue, 28 Jul 2009 12:36:00 GMT</pubDate>
      <guid>3_3137511</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>My java output is running but the output does not follow assignment format</title>
      <description>How can my output have the same structure/output as the sample output&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain111398'&gt;&lt;div&gt;Output&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode111398' class='copy-code' data-index='111398' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre111398' style='margin-top:0;' class='lang-output' data-language='Output' data-allowShrink='True' data-collapse='False'&gt;
Technician ID: FT1001

Name: David Jonathan

Salary: 50000.0

Calculated Salary: 50000.0

 

Technician ID: PTE2001

Name: Keith Peters

Salary: 24.5

Calculated Salary: 980.0

 

Technician ID: FTE1003

Name: Mary Aramal

Salary: 60000.0

Calculated Salary: 60000.0&lt;/pre&gt;&lt;br /&gt;
 &lt;br /&gt;
my output : &lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain333120'&gt;&lt;div&gt;Output&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode333120' class='copy-code' data-index='333120' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre333120' style='margin-top:0;' class='lang-output' data-language='Output' data-allowShrink='True' data-collapse='False'&gt;
FullTime,David Jonathan,FT1001,50000
PartTime,Keith Peters,PTE2001,24.5 
FullTime,Mary Aramal,FTE1003,60000
PartTime,Hassan Otosh ,PTE2002,30.5 
FullTime,Bernard Becker,FTE1004,40000
PartTime,Roselyn Anne,PTE2003,24.5 
FullTime,James Lead,FTE1005,80000&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
my main class :&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain46399'&gt;&lt;div&gt;Java&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode46399' class='copy-code' data-index='46399' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre46399' style='margin-top:0;' class='lang-java' data-language='Java' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; main(&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt;[]args) {
		&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; relativePath = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;data/technicians.csv"&lt;/span&gt;;
		List&amp;lt;BaseTechnician&amp;gt; technicians = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ArrayList&amp;lt;&amp;gt;();

			
			List&amp;lt;String[]&amp;gt; data = CSVReader.readTechnicians(relativePath);
			
			&lt;span class="code-keyword"&gt;if&lt;/span&gt;(data != null) {
		
		
		&lt;span class="code-keyword"&gt;for&lt;/span&gt;(&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt;[]technician : data) {
			
			&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; position = technician[&lt;span class="code-digit"&gt;0&lt;/span&gt;];
			
			
			BaseTechnician emp;
			&lt;span class="code-keyword"&gt;switch&lt;/span&gt;(position) {
			&lt;span class="code-keyword"&gt;case&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; Fulltime "&lt;/span&gt;:
			 emp = &lt;span class="code-keyword"&gt;new&lt;/span&gt; FullTimeTechnician(technician[&lt;span class="code-digit"&gt;1&lt;/span&gt;], technician[&lt;span class="code-digit"&gt;2&lt;/span&gt;],Double.parseDouble(technician[&lt;span class="code-digit"&gt;3&lt;/span&gt;]));
			&lt;span class="code-keyword"&gt;break&lt;/span&gt;;
			&lt;span class="code-keyword"&gt;case&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; PartTime "&lt;/span&gt;:
			 emp = &lt;span class="code-keyword"&gt;new&lt;/span&gt; PartTimeTechnician(technician[&lt;span class="code-digit"&gt;1&lt;/span&gt;], technician[&lt;span class="code-digit"&gt;2&lt;/span&gt;],Double.parseDouble(technician[&lt;span class="code-digit"&gt;3&lt;/span&gt;]));
				&lt;span class="code-keyword"&gt;break&lt;/span&gt;;
				&lt;span class="code-keyword"&gt;default&lt;/span&gt;:
					System.out.println( position);
					&lt;span class="code-keyword"&gt;continue&lt;/span&gt;;
					
					
			}
			technicians.add(emp);
			
			&lt;span class="code-keyword"&gt;for&lt;/span&gt;(BaseTechnician tech : technicians ) {
				tech.displayDetails();
				
			}
			
		}
		} &lt;span class="code-keyword"&gt;else&lt;/span&gt; {
			System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Error Failed to read data from the technician CSV file "&lt;/span&gt;);
		}
		
	}
	
	
}&lt;/pre&gt;</description>
      <author>Olivia8</author>
      <link>https://www.codeproject.com/Messages/5993960/My-java-output-is-running-but-the-output-does-not</link>
      <pubDate>Mon, 25 Mar 2024 06:18:00 GMT</pubDate>
      <guid>3_5993960</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Java assignmnent due tonigh!!  error message "Index 1 out of bounds for length 1"</title>
      <description>I have an assignment where the main class output mentions Index 1 out of bounds for length 1 and im trying to read a csv file which has 4 rows and 4 columns below is my code and csv file. Please help the assignment is due tonight at midnight Eastern time :/ I am in my first year of computer science and the assignment is for my introduction of Object-oriented programing, I still consider myself beginner.&lt;br /&gt;
&lt;br /&gt;
main class:&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain451527'&gt;&lt;div&gt;Java&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode451527' class='copy-code' data-index='451527' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre451527' style='margin-top:0;' class='lang-java' data-language='Java' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; main(&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt;[]args) {
		&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; relativePath = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;data/technicians 2.numbers"&lt;/span&gt;;
		List&amp;lt;BaseTechnician&amp;gt; technicians = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ArrayList&amp;lt;&amp;gt;();

		
		&lt;span class="code-keyword"&gt;try&lt;/span&gt; {
			
			List&amp;lt;String[]&amp;gt; data = CSVReader.readTechnicians(relativePath);
			
			&lt;span class="code-keyword"&gt;if&lt;/span&gt;(data != null) {
		
		
		&lt;span class="code-keyword"&gt;for&lt;/span&gt;(&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt;[]technician : data) {
			&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; position = technician[&lt;span class="code-digit"&gt;0&lt;/span&gt;];
			&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; name = technician[&lt;span class="code-digit"&gt;1&lt;/span&gt;];
			&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; technicianId = technician[&lt;span class="code-digit"&gt;2&lt;/span&gt;];
			&lt;span class="code-keyword"&gt;double&lt;/span&gt; salaryOrHourlyRate = Double.parseDouble(technician[&lt;span class="code-digit"&gt;3&lt;/span&gt;]);
			
			BaseTechnician emp;
			&lt;span class="code-keyword"&gt;switch&lt;/span&gt;(position) {
			&lt;span class="code-keyword"&gt;case&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; Fulltime "&lt;/span&gt;:
			 emp = &lt;span class="code-keyword"&gt;new&lt;/span&gt; FullTimeTechnician(name, technicianId,salaryOrHourlyRate);
			&lt;span class="code-keyword"&gt;break&lt;/span&gt;;
			&lt;span class="code-keyword"&gt;case&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; PartTime "&lt;/span&gt;:
			 emp = &lt;span class="code-keyword"&gt;new&lt;/span&gt; PartTimeTechnician(name, technicianId, salaryOrHourlyRate);
				&lt;span class="code-keyword"&gt;break&lt;/span&gt;;
				&lt;span class="code-keyword"&gt;default&lt;/span&gt;:
					System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; Wrong technician position "&lt;/span&gt;);
					&lt;span class="code-keyword"&gt;continue&lt;/span&gt;;
			}
			technicians.add(emp);
			
			&lt;span class="code-keyword"&gt;for&lt;/span&gt;(BaseTechnician tech : technicians ) {
				tech.displayDetails();
				System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; Calculated Salary : "&lt;/span&gt; + tech.calculateSalary());
				System.out.println();
			}
			
		}
		} &lt;span class="code-keyword"&gt;else&lt;/span&gt; {
			System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Error Failed to read data from the technician CSV file "&lt;/span&gt;);
		}
		
	} &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (Exception e) {
		System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; Error occured "&lt;/span&gt; + e.getMessage() );
	}
		
	}
	
	
}&lt;/pre&gt; &lt;br /&gt;
&lt;br /&gt;
and csv file:&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain978062'&gt;&lt;div&gt;CSV&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode978062' class='copy-code' data-index='978062' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre978062' style='margin-top:0;' class='lang-csv' data-language='CSV' data-allowShrink='True' data-collapse='False'&gt;
FullTime	David Jonathan	FT1001	&lt;span class="code-digit"&gt;50000&lt;/span&gt;
PartTime	Keith Peters	PTE&amp;#160;&lt;span class="code-digit"&gt;2001&lt;/span&gt;.&lt;span class="code-digit"&gt;00&lt;/span&gt;	&lt;span class="code-digit"&gt;24&lt;/span&gt;.&lt;span class="code-digit"&gt;5&lt;/span&gt;
FullTime	Mary Aramal	FTE1003	&lt;span class="code-digit"&gt;60000&lt;/span&gt;
PartTime	Hassan Otosh 	PTE&amp;#160;&lt;span class="code-digit"&gt;2002&lt;/span&gt;.&lt;span class="code-digit"&gt;00&lt;/span&gt;	&lt;span class="code-digit"&gt;30&lt;/span&gt;.&lt;span class="code-digit"&gt;5&lt;/span&gt;
FullTime	Bernard Becker	FTE1004	&lt;span class="code-digit"&gt;40000&lt;/span&gt;
PartTime	Roselyn Anne	PTE&amp;#160;&lt;span class="code-digit"&gt;2003&lt;/span&gt;.&lt;span class="code-digit"&gt;00&lt;/span&gt;	&lt;span class="code-digit"&gt;24&lt;/span&gt;.&lt;span class="code-digit"&gt;5&lt;/span&gt;
FullTime	James Lead	FTE1005	&lt;span class="code-digit"&gt;80000&lt;/span&gt;&lt;/pre&gt;</description>
      <author>Olivia8</author>
      <link>https://www.codeproject.com/Messages/5993925/Java-assignmnent-due-tonigh-error-message-Index-1</link>
      <pubDate>Sun, 24 Mar 2024 16:23:00 GMT</pubDate>
      <guid>3_5993925</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Security Manager gone</title>
      <description>The SecurityManager is being removed from Java?&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://openjdk.org/jeps/411"&gt;JEP 411: Deprecate the Security Manager for Removal&lt;/a&gt;[&lt;a href="https://openjdk.org/jeps/411" target="_blank" title="New Window"&gt;^&lt;/a&gt;]&lt;br /&gt;
&lt;br /&gt;
For a certain class of problems I found that to be a solution.  Without it there is no solution.  Certainly in C# such a solution does not exist.&lt;br /&gt;
&lt;br /&gt;
The class of problems is one where the business model allows, as a selling point, customers to create their own code for limited solutions.  &lt;br /&gt;
&lt;br /&gt;
For example (and from a real company) if one allows for Content Management creation then allowing for programmatic creation provides many possibilities.  But running that in a shared application space means that the company will want to limit access.  Not only things like operating system calls but even to make sure that the customer code doesn't spin up 100 threads.&lt;br /&gt;
&lt;br /&gt;
The SecurityManager allows one to prevent that.&lt;br /&gt;
&lt;br /&gt;
Alternatives are not as elegant as it requires spinning up a new process and limiting, some functionality, by the access that the user has.&lt;br /&gt;
&lt;br /&gt;
It is this one feature that I found made Java better than C#.</description>
      <author>jschell</author>
      <link>https://www.codeproject.com/Messages/5993434/Security-Manager-gone</link>
      <pubDate>Wed, 20 Mar 2024 22:52:00 GMT</pubDate>
      <guid>3_5993434</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>large numbers</title>
      <description>How do you separate large numbers in Java?  I want to use something like commas.&lt;br /&gt;
&lt;br /&gt;
I think this works in C++, but it doesn't work in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain400205'&gt;&lt;div&gt;C++&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode400205' class='copy-code' data-index='400205' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre400205' style='margin-top:0;' class='lang-cplusplus' data-language='C++' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;int&lt;/span&gt; onebillion = &lt;span class="code-digit"&gt;1&amp;#39;000&amp;#39;000&amp;#39;000&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Anyone know?&lt;br /&gt;
&lt;br /&gt;
Thanks.</description>
      <author>mike7411</author>
      <link>https://www.codeproject.com/Messages/5982410/large-numbers</link>
      <pubDate>Sun, 14 Jan 2024 23:58:00 GMT</pubDate>
      <guid>3_5982410</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Please help me with this password validation - While Loop Running Once</title>
      <description>I am tryint to validate a password that has the following rules: can't be the same as username, at least 8 characters, and must have a uppercase letter and special character. Any help you can offer would be AMAZING!  &lt;img src="https://www.codeproject.com/script/Forums/Images/smiley_smile.gif" align="top" alt="Smile | :)" /&gt;  &lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain31013'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode31013' class='copy-code' data-index='31013' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre31013' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
import java.util.Scanner;


&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; Main {
    &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; userName = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;johndoe"&lt;/span&gt;;
    &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; password = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;ABC_1234"&lt;/span&gt;;
    &lt;span class="code-keyword"&gt;static&lt;/span&gt; boolean validPassword = &lt;span class="code-keyword"&gt;false&lt;/span&gt;;

    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; main(String[] args) {
        System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Please Change Your Password"&lt;/span&gt;);

        System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;
                Please make sure it is 8 characters long,
                Contains an uppercase letter,
                Contains a special character,
                Does not contain your username,
                And is not the same as the previous password
                "&lt;/span&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;);

        checkPassword();
    }

    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; checkPassword() {
        System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println();
        System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.print(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;What is your new password? "&lt;/span&gt;);
        Scanner scanner = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Scanner(System.&lt;span class="code-keyword"&gt;in&lt;/span&gt;);
        &lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; newPassword = scanner.next();
        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;System.out.println(newPassword);&lt;/span&gt;

        &lt;span class="code-keyword"&gt;while&lt;/span&gt; (!validPassword) {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (newPassword.equalsIgnoreCase(userName)) {
                System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Your password can&amp;#39;t be the same as your username"&lt;/span&gt;);
                System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.print(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;What is your new password? "&lt;/span&gt;);
                newPassword = scanner.next();


            }
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (newPassword.length() &amp;lt; &lt;span class="code-digit"&gt;8&lt;/span&gt;) {
                System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;You password must be at least 8 characters"&lt;/span&gt;);
                System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.print(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;What is your new password? "&lt;/span&gt;);
                newPassword = scanner.next();
                &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;validPassword = true;&lt;/span&gt;
            }
            &lt;span class="code-keyword"&gt;for&lt;/span&gt; (&lt;span class="code-keyword"&gt;int&lt;/span&gt; i = &lt;span class="code-digit"&gt;0&lt;/span&gt;; i &amp;lt; newPassword.length(); i++) {
                &lt;span class="code-keyword"&gt;char&lt;/span&gt; ch = newPassword.charAt(i);
                &lt;span class="code-keyword"&gt;if&lt;/span&gt; (!Character.isUpperCase(ch) || (Character.isDigit(ch) &amp;amp;&amp;amp; Character.isLetter(ch) &amp;amp;&amp;amp; Character.isWhitespace(ch))) {
                    System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Please make sure your password has an uppercase and/or special character"&lt;/span&gt;);
                    newPassword = scanner.next();
                    validPassword = &lt;span class="code-keyword"&gt;true&lt;/span&gt;;
                } &lt;span class="code-keyword"&gt;else&lt;/span&gt; {
                    System.&lt;span class="code-keyword"&gt;out&lt;/span&gt;.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;stop"&lt;/span&gt;);
                    validPassword = &lt;span class="code-keyword"&gt;false&lt;/span&gt;;
                }
            }
        }
    }
}&lt;/pre&gt;</description>
      <author>R1s1ng Phoen1x</author>
      <link>https://www.codeproject.com/Messages/5982363/Please-help-me-with-this-password-validation-While</link>
      <pubDate>Sun, 14 Jan 2024 15:35:00 GMT</pubDate>
      <guid>3_5982363</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>viewing Java disassembly</title>
      <description>I am in IntelliJ IDEA.  I want to view the disassembly of this code to see if it does two comparisons:&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain75494'&gt;&lt;div&gt;Java&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode75494' class='copy-code' data-index='75494' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre75494' style='margin-top:0;' class='lang-java' data-language='Java' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;if&lt;/span&gt; (-&lt;span class="code-digit"&gt;0&lt;/span&gt;.&lt;span class="code-digit"&gt;0&lt;/span&gt; == &lt;span class="code-digit"&gt;0&lt;/span&gt;.&lt;span class="code-digit"&gt;0&lt;/span&gt;) System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;they&amp;#39;re equal"&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;
Based on searching, it sounds like IntelliJ can't do that.  Anyone know of a Java IDE that can do this?&lt;br /&gt;
&lt;br /&gt;
Thank you.</description>
      <author>mike7411</author>
      <link>https://www.codeproject.com/Messages/5982141/viewing-Java-disassembly</link>
      <pubDate>Fri, 12 Jan 2024 09:55:00 GMT</pubDate>
      <guid>3_5982141</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>How can I integrate ChatGPT into my Spring Boot application?</title>
      <description>Hi everyone! I want to integrate ChatGPT into my Spring Boot app. How can I do this?</description>
      <author>Nata Bil</author>
      <link>https://www.codeproject.com/Messages/5979776/How-can-I-integrate-ChatGPT-into-my-Spring-Boot-ap</link>
      <pubDate>Thu, 28 Dec 2023 09:57:00 GMT</pubDate>
      <guid>3_5979776</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>debugger stop button behaving weirdly</title>
      <description>I am using IntelliJ IDEA 2023.3.1 (Community Edition), and I'm seeing some weirdness.&lt;br /&gt;
&lt;br /&gt;
I made a simple test.&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain91067'&gt;&lt;div&gt;Java&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode91067' class='copy-code' data-index='91067' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre91067' style='margin-top:0;' class='lang-java' data-language='Java' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; SimpleBreakTest {

    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; main(&lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt;[] args) {
        &lt;span class="code-sdkkeyword"&gt;String&lt;/span&gt; a = null;
        a.toUpperCase();
    }


}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I put a breakpoint on the first line:&lt;br /&gt;
        String a = null;&lt;br /&gt;
&lt;br /&gt;
Then, I debugged the program, and it stopped at the breakpoint.  Then, I pressed the "Stop" button in the debugger.&lt;br /&gt;
&lt;br /&gt;
Instead of stopping execution, it looks like it continued because it printed out this message:&lt;br /&gt;
&lt;br /&gt;
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because "a" is null&lt;br /&gt;
	at SimpleBreakTest.main(SimpleBreakTest.java:5)&lt;br /&gt;
&lt;br /&gt;
Any ideas why the stop button in the debugger doesn't seem to work right?&lt;br /&gt;
&lt;br /&gt;
Thanks.</description>
      <author>mike7411</author>
      <link>https://www.codeproject.com/Messages/5978829/debugger-stop-button-behaving-weirdly</link>
      <pubDate>Thu, 21 Dec 2023 06:08:00 GMT</pubDate>
      <guid>3_5978829</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Intellij</title>
      <description>Friends, how do I use that NetBeens form called "desktop panel", like putting one form inside another. It's that form that traps the other inside it, not letting the form leave the delimited area.&lt;br /&gt;
I'm using Intelli</description>
      <author>anderson mendes 2023</author>
      <link>https://www.codeproject.com/Messages/5977324/Intellij</link>
      <pubDate>Tue, 12 Dec 2023 20:13:00 GMT</pubDate>
      <guid>3_5977324</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Java strings</title>
      <description>I heard that Java string characters are 16-bit.  Is this true?&lt;br /&gt;
&lt;br /&gt;
Does this mean that certain Unicode characters can't be represented since there are about 150,000 Unicode characters?&lt;br /&gt;
&lt;br /&gt;
Thank you.</description>
      <author>mike7411</author>
      <link>https://www.codeproject.com/Messages/5976212/Java-strings</link>
      <pubDate>Tue, 05 Dec 2023 03:12:00 GMT</pubDate>
      <guid>3_5976212</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>&amp;lt;pre&amp;gt;Problems enlarging Eclipse icons</title>
      <description>Hello, good day, I have 2 problems.&lt;br /&gt;
1. I can't find the installation path or the option mentioned in this post doesn't appear.&lt;br /&gt;
https://stackoverflow.com/questions/20718093/eclipse-interface-icons-very-small-on-high-resolution-screen-in-windows-8-1&lt;br /&gt;
2. Modifying the eclipse .ini file actually enlarges the icons but deconfigures my entire eclipse.&lt;br /&gt;
How can I solve it? Thank you.</description>
      <author>BrunoV2022</author>
      <link>https://www.codeproject.com/Messages/5973732/lt-pre-gt-Problems-enlarging-Eclipse-icons</link>
      <pubDate>Sun, 19 Nov 2023 21:57:00 GMT</pubDate>
      <guid>3_5973732</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>How to convert string to double with trailing zeros after decimal</title>
      <description>Any suggestions in Java for the following scenario:&lt;br /&gt;
&lt;br /&gt;
Actually its truncating trailing zeros when converting to double.&lt;br /&gt;
Ex-1:&lt;br /&gt;
String - "123.4000"&lt;br /&gt;
double - 123.4000&lt;br /&gt;
&lt;br /&gt;
Ex-2:&lt;br /&gt;
String - "123.4560"&lt;br /&gt;
double - 123.4560</description>
      <author>Member 16135433</author>
      <link>https://www.codeproject.com/Messages/5971933/How-to-convert-string-to-double-with-trailing-zero</link>
      <pubDate>Wed, 08 Nov 2023 12:46:00 GMT</pubDate>
      <guid>3_5971933</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>How to use JNI without setting Environment Variables</title>
      <description>I found the following code posted by &lt;a href="https://www.codeproject.com/Members/Richard-MacCutchan"&gt;@Richard-MacCutchan&lt;/a&gt; to a thread about how to use JNI without having to add the location of &lt;b&gt;jvm.dll&lt;/b&gt; into &lt;b&gt;Environment Variables&lt;/b&gt;. I kinda understood how it works but still...&lt;br /&gt;
&lt;br /&gt;
&lt;div class='pre-lang' id='premain720135'&gt;&lt;div&gt;C++&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode720135' class='copy-code' data-index='720135' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre720135' style='margin-top:0;' class='lang-cplusplus' data-language='C++' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-comment"&gt;/*&lt;/span&gt;&lt;span class="code-comment"&gt;
 ******************************************************************************
 *
 *    Name     : cpptojava.cpp
 *
 *    Function : Basic Console application to call a Java class.
 *
 *    Created  : 09 Jun 2022
 *
 ******************************************************************************
 */&lt;/span&gt;

&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Windows.h&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;iostream&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;string&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;sstream&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;vector&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;filesystem&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt; // requires -std:c++17
&lt;/span&gt;
&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;jni.h"&lt;/span&gt;
&lt;/span&gt;
&lt;span class="code-comment"&gt;//
&lt;/span&gt;&lt;span class="code-comment"&gt;// Find the path to the jvm.dll given the base path to the Java runtime (or JDK if installed)
&lt;/span&gt;&lt;span class="code-comment"&gt;//
&lt;/span&gt;HMODULE LoadDll(
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* jrePath
)
{
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* pszjvmname = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;bin\\server\\jvm.dll"&lt;/span&gt;;   &lt;span class="code-comment"&gt;// Java VM name
&lt;/span&gt;    HMODULE hJVMDLL = &lt;span class="code-digit"&gt;0&lt;/span&gt;;

    std::filesystem::path jvmpath(jrePath);
    jvmpath /= pszjvmname;
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (!std::filesystem::exists(jvmpath))
    {
        &lt;span class="code-sdkkeyword"&gt;std::cerr&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JVM library "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; jvmpath &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt; not found."&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
        &lt;span class="code-comment"&gt;// throw an exception 
&lt;/span&gt;    }

    &lt;span class="code-comment"&gt;// load the Java VM DLL into our address space
&lt;/span&gt;    &lt;span class="code-comment"&gt;// NB filesystem::path is Unicode
&lt;/span&gt;    hJVMDLL = LoadLibraryW(&lt;span class="code-keyword"&gt;reinterpret_cast&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;PCWSTR&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;(jvmpath.c_str()));
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (hJVMDLL != NULL)
    {
        &lt;span class="code-sdkkeyword"&gt;std::clog&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;jvm.dll loaded from: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; jvmpath &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
    }
    &lt;span class="code-keyword"&gt;return&lt;/span&gt; hJVMDLL; &lt;span class="code-comment"&gt;// a Windows HANDLE to the DLL
&lt;/span&gt;}


&lt;span class="code-comment"&gt;//
&lt;/span&gt;&lt;span class="code-comment"&gt;// A function to load the Java VM and initialise the JNI interface
&lt;/span&gt;&lt;span class="code-comment"&gt;// There are a number of diagnostic messages to show progress
&lt;/span&gt;&lt;span class="code-comment"&gt;//
&lt;/span&gt;JNIEnv* AttachJVM(
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* jrePath,
    JavaVM* jvm,
    &lt;span class="code-sdkkeyword"&gt;std::string&lt;/span&gt; strcwd
)
{
    HMODULE     hJVMDLL = LoadDll(jrePath);
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (hJVMDLL == &lt;span class="code-digit"&gt;0&lt;/span&gt;)
    {
        &lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;;
    }
    &lt;span class="code-keyword"&gt;typedef&lt;/span&gt; jint(JNICALL* fpCJV)(JavaVM**, &lt;span class="code-keyword"&gt;void&lt;/span&gt;**, &lt;span class="code-keyword"&gt;void&lt;/span&gt;*);
    fpCJV JNI_CreateJavaVM = (fpCJV)::GetProcAddress(hJVMDLL, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_CreateJavaVM"&lt;/span&gt;);

    &lt;span class="code-comment"&gt;// tell the JVM where to find the class
&lt;/span&gt;    JavaVMOption    options[&lt;span class="code-digit"&gt;2&lt;/span&gt;];
    &lt;span class="code-sdkkeyword"&gt;std::stringstream&lt;/span&gt; ssoptions;
    ssoptions &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;-Djava.class.path="&lt;/span&gt;;
    ssoptions &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; strcwd;
    &lt;span class="code-sdkkeyword"&gt;std::string&lt;/span&gt; stropts = ssoptions.str();
    options[&lt;span class="code-digit"&gt;0&lt;/span&gt;].optionString = &lt;span class="code-keyword"&gt;const_cast&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;char&lt;/span&gt;*&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;(stropts.c_str());
    options[&lt;span class="code-digit"&gt;1&lt;/span&gt;].optionString = &lt;span class="code-keyword"&gt;const_cast&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;char&lt;/span&gt;*&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;-verbose:jni"&lt;/span&gt;);   &lt;span class="code-comment"&gt;// print JNI-related messages
&lt;/span&gt;
    JavaVMInitArgs  vm_args; &lt;span class="code-comment"&gt;// JDK/JRE 6 VM initialization arguments
&lt;/span&gt;    vm_args.version = JNI_VERSION_1_8;
    vm_args.nOptions = &lt;span class="code-digit"&gt;1&lt;/span&gt;; &lt;span class="code-comment"&gt;// change to 2 for verbose output
&lt;/span&gt;    vm_args.ignoreUnrecognized = &lt;span class="code-keyword"&gt;false&lt;/span&gt;;
    vm_args.options = options;
    &lt;span class="code-keyword"&gt;for&lt;/span&gt; (&lt;span class="code-keyword"&gt;int&lt;/span&gt; i = &lt;span class="code-digit"&gt;0&lt;/span&gt;; i &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; vm_args.nOptions; ++i)
    {
        &lt;span class="code-sdkkeyword"&gt;std::clog&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Options["&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; i &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;]: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; options[i].optionString &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
    }
    JNIEnv* env;            &lt;span class="code-comment"&gt;// pointer to native method interface
&lt;/span&gt;    jint res = JNI_CreateJavaVM(&amp;amp;jvm, (&lt;span class="code-keyword"&gt;void&lt;/span&gt;**)&amp;amp;env, &amp;amp;vm_args);
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (res != &lt;span class="code-digit"&gt;0&lt;/span&gt;)
    {
        &lt;span class="code-sdkkeyword"&gt;std::cerr&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: JNI_CreateJavaVM returned: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; res &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
    }
    jint version = env-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;GetVersion();
    &lt;span class="code-sdkkeyword"&gt;std::clog&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JVM Version: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; (version &lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt; &lt;span class="code-digit"&gt;16&lt;/span&gt;) &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;."&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; (version &amp;amp; &lt;span class="code-digit"&gt;0xffff&lt;/span&gt;) &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;

    &lt;span class="code-keyword"&gt;return&lt;/span&gt; env; &lt;span class="code-comment"&gt;// the pointer to the jvm dll
&lt;/span&gt;}


&lt;span class="code-keyword"&gt;void&lt;/span&gt; CallClass(
    JNIEnv* jniEnv,
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* pszClassname,
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* pszMethodname,
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* pszSignature
)
{
    jclass jvmclass = jniEnv-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;FindClass(pszClassname);
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (jvmclass != NULL)
    {
        &lt;span class="code-sdkkeyword"&gt;std::cout&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: Found the class: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; pszClassname &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
        jmethodID jmid = jniEnv-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;GetStaticMethodID(jvmclass, pszMethodname, pszSignature);
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (jmid != NULL)
        {
            &lt;span class="code-sdkkeyword"&gt;std::cout&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: Found the method: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; pszMethodname &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
            jniEnv-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;CallStaticVoidMethod(jvmclass, jmid, NULL);
            &lt;span class="code-sdkkeyword"&gt;std::cout&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: env-&amp;gt;CallStaticVoidMethod complete"&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
        }
        &lt;span class="code-keyword"&gt;else&lt;/span&gt;
        {
            &lt;span class="code-sdkkeyword"&gt;std::cerr&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: Failed to find the method: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; pszMethodname &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
        }
    }
    &lt;span class="code-keyword"&gt;else&lt;/span&gt;
    {
        &lt;span class="code-sdkkeyword"&gt;std::cerr&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: Failed to find the class: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; pszClassname &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
    }
}


&lt;span class="code-keyword"&gt;int&lt;/span&gt; main(
    &lt;span class="code-keyword"&gt;int&lt;/span&gt; argc,
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;** argv
)
{
    &lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* jreDir = &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;;

    &lt;span class="code-comment"&gt;// suppress debug messages
&lt;/span&gt;    &lt;span class="code-sdkkeyword"&gt;std::clog&lt;/span&gt;.setstate(std::ios::badbit);
    &lt;span class="code-keyword"&gt;for&lt;/span&gt; (argv++; argc &lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt; &lt;span class="code-digit"&gt;1&lt;/span&gt;; ++argv, --argc)
    {
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (*argv[&lt;span class="code-digit"&gt;0&lt;/span&gt;] == &lt;span class="code-string"&gt;&amp;#39;&lt;/span&gt;&lt;span class="code-string"&gt;-&amp;#39;&lt;/span&gt;)
        {
            &lt;span class="code-comment"&gt;// handle any execution options ...
&lt;/span&gt;            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (strstr(*argv, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;-d"&lt;/span&gt;))
                &lt;span class="code-sdkkeyword"&gt;std::clog&lt;/span&gt;.clear();
        }
        &lt;span class="code-keyword"&gt;else&lt;/span&gt;
        {
            jreDir = *argv;
        }
    }
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (jreDir == &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;)
    {
        &lt;span class="code-sdkkeyword"&gt;std::cerr&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;No root path provided for JVM."&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
        &lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-digit"&gt;1&lt;/span&gt;;
    }
    JNIEnv* jniEnv = NULL;
    std::filesystem::path cwd = std::filesystem::current_path();
    JavaVM jvm;
    jniEnv = AttachJVM(jreDir, &amp;amp;jvm, cwd.string());
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (jniEnv == NULL)
    {
        &lt;span class="code-sdkkeyword"&gt;std::cerr&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: Failed to get Java environment"&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
        &lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-digit"&gt;1&lt;/span&gt;;
    }
        CallClass(jniEnv, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;CppToJava"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;main"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;([Ljava/lang/String;)V"&lt;/span&gt;);

    &lt;span class="code-comment"&gt;// clean up
&lt;/span&gt;    jint jvmres = jvm.DestroyJavaVM(); &lt;span class="code-comment"&gt;// never returns ???
&lt;/span&gt;    &lt;span class="code-sdkkeyword"&gt;std::clog&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;C++: DestroyJavaVM and terminate: "&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; jvmres &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;

}&lt;/pre&gt;&lt;br /&gt;
I have two minor problems, I get a bit lost, I understand that it looks to see if Java in installed and tries to get the path to it and then to load the DLL, but I didn't managed to make it work for my situation, and also, on client machines I'm not making them install Java, but it comes in the app files with a license agreement, I'm using Eclipse Adoptium (&lt;b&gt;...\MyApp\ThirdParty\Eclipse Adoptium\jre-17.0.7.7-hotspot&lt;/b&gt;).&lt;br /&gt;
&lt;br /&gt;
If it isn't much to ask, could someone help me change the above code so that it will work in this scenario: Before creating the JVM, I'm running some other functions, and one of them returns the location for the app folder (ex: &lt;b&gt;D:\Program Files\MyApp&lt;/b&gt;). Inside that folder are the apps data, and a folder &lt;b&gt;Data&lt;/b&gt;, inside it a folder &lt;b&gt;Java&lt;/b&gt;, and inside that all the java class files (&lt;b&gt;...\MyApp\Data\Java\JavaMethods.class&lt;/b&gt;). So because I know the location of the app, I can give the location for &lt;b&gt;jvm.dll&lt;/b&gt; by using the variable &lt;b&gt;std::string location&lt;/b&gt; which would have as an example &lt;b&gt;D:\Program Files\MyApp&lt;/b&gt;, then to that I can append &lt;b&gt;\ThirdParty\Eclipse Adoptium\jre-17.0.7.7-hotspot\bin\server&lt;/b&gt; for the location of &lt;b&gt;jvm.dll&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
To be more precise, what I need to add before &lt;b&gt;location.insert(0, "-Djava.class.path=");&lt;/b&gt;, to load the &lt;b&gt;jvm.dll&lt;/b&gt; knowing it's location by combining like I said, the value from function parameter which would be set before calling the function and would have as an example &lt;b&gt;D:\Program Files\MyApp&lt;/b&gt;, with &lt;b&gt;\ThirdParty\Eclipse Adoptium\jre-17.0.7.7-hotspot\bin\server&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Here is an example how my app is using JNI extracted to a new project:&lt;br /&gt;
&lt;div class='pre-lang' id='premain225903'&gt;&lt;div&gt;C++&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode225903' class='copy-code' data-index='225903' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre225903' style='margin-top:0;' class='lang-cplusplus' data-language='C++' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;jni.h&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;string&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;iostream&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;chrono&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class="code-keyword"&gt;#include&lt;/span&gt;&lt;span class="code-preprocessor"&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;thread&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;
JavaVM* jvm = &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;;

&lt;span class="code-sdkkeyword"&gt;std::string&lt;/span&gt; createVM(&lt;span class="code-sdkkeyword"&gt;std::string&lt;/span&gt; location) {
	&lt;span class="code-comment"&gt;//Here what I need to add to load the dll from location + ThirdParty\Eclipse Adoptium\jre-17.0.7.7-hotspot\bin\server
&lt;/span&gt;	location.insert(&lt;span class="code-digit"&gt;0&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;-Djava.class.path="&lt;/span&gt;);
	location.append(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Data\\Java"&lt;/span&gt;);
	JavaVMInitArgs vm_args;
	JavaVMOption* options = &lt;span class="code-keyword"&gt;new&lt;/span&gt; JavaVMOption[&lt;span class="code-digit"&gt;1&lt;/span&gt;];
	options[&lt;span class="code-digit"&gt;0&lt;/span&gt;].optionString = &amp;amp;location[&lt;span class="code-digit"&gt;0&lt;/span&gt;];
	vm_args.version = JNI_VERSION_10;
	vm_args.nOptions = &lt;span class="code-digit"&gt;1&lt;/span&gt;;
	vm_args.options = options;
	vm_args.ignoreUnrecognized = &lt;span class="code-keyword"&gt;false&lt;/span&gt;;
	JNIEnv* env = &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;;
	jint rc = JNI_OK;
	&lt;span class="code-keyword"&gt;if&lt;/span&gt; (jvm == &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;) {
		rc = JNI_CreateJavaVM(&amp;amp;jvm, (&lt;span class="code-keyword"&gt;void&lt;/span&gt;**)&amp;amp;env, &amp;amp;vm_args);
	}
	&lt;span class="code-keyword"&gt;else&lt;/span&gt; {
		rc = jvm-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;AttachCurrentThread((&lt;span class="code-keyword"&gt;void&lt;/span&gt;**)&amp;amp;env, NULL);
	}
	&lt;span class="code-keyword"&gt;delete&lt;/span&gt;[] options;
	&lt;span class="code-keyword"&gt;if&lt;/span&gt; (rc != JNI_OK) {
		&lt;span class="code-keyword"&gt;if&lt;/span&gt; (rc == JNI_EVERSION)
			&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_EVERSION"&lt;/span&gt;;
		&lt;span class="code-keyword"&gt;else&lt;/span&gt; &lt;span class="code-keyword"&gt;if&lt;/span&gt; (rc == JNI_ENOMEM)
			&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_ENOMEM"&lt;/span&gt;;
		&lt;span class="code-keyword"&gt;else&lt;/span&gt; &lt;span class="code-keyword"&gt;if&lt;/span&gt; (rc == JNI_EINVAL)
			&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_EINVAL"&lt;/span&gt;;
		&lt;span class="code-keyword"&gt;else&lt;/span&gt; &lt;span class="code-keyword"&gt;if&lt;/span&gt; (rc == JNI_EEXIST)
			&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_EEXIST"&lt;/span&gt;;
		&lt;span class="code-keyword"&gt;else&lt;/span&gt;
			&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_FATALERROR"&lt;/span&gt;;
	}
	&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JNI_CREATED"&lt;/span&gt;;
}

&lt;span class="code-sdkkeyword"&gt;std::string&lt;/span&gt; createIdentification() {
	JNIEnv* env;
	jvm-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;AttachCurrentThread((&lt;span class="code-keyword"&gt;void&lt;/span&gt;**)&amp;amp;env, NULL);
	jclass jClass = env-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;FindClass(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;JavaMethods"&lt;/span&gt;);

	&lt;span class="code-keyword"&gt;if&lt;/span&gt; (jClass == &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;) {
		&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;ClassNotFound cI"&lt;/span&gt;;
	}
	&lt;span class="code-keyword"&gt;else&lt;/span&gt; {
		jmethodID methodID = env-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;GetStaticMethodID(jClass, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;createIdentification"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;()Ljava/lang/String;"&lt;/span&gt;);
		&lt;span class="code-keyword"&gt;if&lt;/span&gt; (methodID == &lt;span class="code-keyword"&gt;nullptr&lt;/span&gt;) {
			&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;MethodNotFound cI"&lt;/span&gt;;
		}
		&lt;span class="code-keyword"&gt;else&lt;/span&gt; {
			jboolean isCopy;
			jstring jResult = (jstring)env-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;CallStaticObjectMethod(jClass, methodID);
			&lt;span class="code-keyword"&gt;const&lt;/span&gt; &lt;span class="code-keyword"&gt;char&lt;/span&gt;* string = env-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;GetStringUTFChars(jResult, &amp;amp;isCopy);
			&lt;span class="code-sdkkeyword"&gt;std::string&lt;/span&gt; result = string;
			env-&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;ReleaseStringUTFChars(jResult, string);

			&lt;span class="code-keyword"&gt;return&lt;/span&gt; result;
		}
	}
}

&lt;span class="code-keyword"&gt;int&lt;/span&gt; main() {
	&lt;span class="code-comment"&gt;//As an example I wrote a possible location
&lt;/span&gt;	&lt;span class="code-sdkkeyword"&gt;std::cout&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; createVM(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;D:\\Program Files\\MyApp\\"&lt;/span&gt;).c_str() &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; &lt;span class="code-sdkkeyword"&gt;std::endl&lt;/span&gt;;
	&lt;span class="code-sdkkeyword"&gt;std::cout&lt;/span&gt; &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt; createIdentification().c_str();

	std::this_thread::sleep_for(std::chrono::milliseconds(&lt;span class="code-digit"&gt;2000&lt;/span&gt;));
	&lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-digit"&gt;0&lt;/span&gt;;
}&lt;/pre&gt;</description>
      <author>Valentinor</author>
      <link>https://www.codeproject.com/Messages/5967421/How-to-use-JNI-without-setting-Environment-Variabl</link>
      <pubDate>Mon, 16 Oct 2023 10:54:00 GMT</pubDate>
      <guid>3_5967421</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Sending file though socket as byte[]</title>
      <description>I have a socket though which I'm sending files. If the file is under the buffer size (8192 in my case) then it is fine, but if the file is over that size, then when it writes to file, it writes the first chunk of 8192 bites every time. I'm using &lt;b&gt;ObjectStream&lt;/b&gt; because beside the file, I'm sending other objects as well in the actual app, but this is the part of sending the file.&lt;br /&gt;
&lt;br /&gt;
Client it sends the file data (testing):&lt;br /&gt;
&lt;div class='pre-lang' id='premain386995'&gt;&lt;div&gt;Java&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode386995' class='copy-code' data-index='386995' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre386995' style='margin-top:0;' class='lang-java' data-language='Java' data-allowShrink='True' data-collapse='False'&gt;
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Starting client"&lt;/span&gt;);
Socket socket = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Socket(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;localhost"&lt;/span&gt;, port);
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Client sending data"&lt;/span&gt;);
ObjectOutputStream dataOut = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ObjectOutputStream(socket.getOutputStream());
BufferedInputStream is = &lt;span class="code-keyword"&gt;new&lt;/span&gt; BufferedInputStream(&lt;span class="code-keyword"&gt;new&lt;/span&gt; FileInputStream(inFile));
&lt;span class="code-keyword"&gt;byte&lt;/span&gt;[] buffer = &lt;span class="code-keyword"&gt;new&lt;/span&gt; &lt;span class="code-keyword"&gt;byte&lt;/span&gt;[&lt;span class="code-digit"&gt;8192&lt;/span&gt;];
&lt;span class="code-keyword"&gt;int&lt;/span&gt; sizeRead = &lt;span class="code-digit"&gt;0&lt;/span&gt;;
&lt;span class="code-keyword"&gt;while&lt;/span&gt; ((sizeRead = is.read(buffer, &lt;span class="code-digit"&gt;0&lt;/span&gt;, &lt;span class="code-digit"&gt;8192&lt;/span&gt;)) &amp;gt;= &lt;span class="code-digit"&gt;0&lt;/span&gt;) {
    printByte(buffer, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;in"&lt;/span&gt;); &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Function that writes to a file as strings the byte[], and after 8192 you can see it is the first byte[] each time, also it writes at the end of file&lt;/span&gt;
    dataOut.writeObject(true);
    dataOut.writeObject(buffer);
    dataOut.writeObject(sizeRead);
    dataOut.flush();
}
is.close();
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Done sending file"&lt;/span&gt;);
dataOut.writeObject(false);
socket.close();
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Client closed"&lt;/span&gt;);
&lt;/pre&gt;&lt;br /&gt;
Server that creates the file:&lt;br /&gt;
&lt;div class='pre-lang' id='premain999515'&gt;&lt;div&gt;Java&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode999515' class='copy-code' data-index='999515' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre999515' style='margin-top:0;' class='lang-java' data-language='Java' data-allowShrink='True' data-collapse='False'&gt;
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Starting server"&lt;/span&gt;);
ServerSocket server = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ServerSocket(port);
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Server waiting"&lt;/span&gt;);
Socket socket = server.accept();
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Client connected"&lt;/span&gt;);
ObjectInputStream dataIn = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ObjectInputStream(socket.getInputStream());
BufferedOutputStream bos = &lt;span class="code-keyword"&gt;new&lt;/span&gt; BufferedOutputStream(&lt;span class="code-keyword"&gt;new&lt;/span&gt; FileOutputStream(outFile));
Object auxKeepReading = dataIn.readObject();
&lt;span class="code-keyword"&gt;if&lt;/span&gt; (auxKeepReading &lt;span class="code-keyword"&gt;instanceof&lt;/span&gt; Boolean) {
    &lt;span class="code-keyword"&gt;while&lt;/span&gt; ((&lt;span class="code-keyword"&gt;boolean&lt;/span&gt;) auxKeepReading) {
        Object auxBuffer = dataIn.readObject();
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (!(auxBuffer &lt;span class="code-keyword"&gt;instanceof&lt;/span&gt; &lt;span class="code-keyword"&gt;byte&lt;/span&gt;[])) {
            System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Broke byte"&lt;/span&gt;);
            &lt;span class="code-keyword"&gt;break&lt;/span&gt;;
        }
        Object auxSize = dataIn.readObject();
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (!(auxSize &lt;span class="code-keyword"&gt;instanceof&lt;/span&gt; Integer)) {
            System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Broke int"&lt;/span&gt;);
            &lt;span class="code-keyword"&gt;break&lt;/span&gt;;
        }
        printByte((&lt;span class="code-keyword"&gt;byte&lt;/span&gt;[]) auxBuffer, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;out"&lt;/span&gt;); &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Same as on client but different file, it writes at the end of file each time&lt;/span&gt;
        bos.write((&lt;span class="code-keyword"&gt;byte&lt;/span&gt;[]) auxBuffer, &lt;span class="code-digit"&gt;0&lt;/span&gt;, (&lt;span class="code-keyword"&gt;int&lt;/span&gt;) auxSize);

        auxKeepReading = dataIn.readObject();
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (!(auxKeepReading &lt;span class="code-keyword"&gt;instanceof&lt;/span&gt; Boolean)) {
            System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Broke boolean"&lt;/span&gt;);
            &lt;span class="code-keyword"&gt;break&lt;/span&gt;;
        }
    }
} &lt;span class="code-keyword"&gt;else&lt;/span&gt; {
    System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Broke boolean"&lt;/span&gt;);
}
bos.close();
socket.close();
server.close();
System.out.println(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Server stopped"&lt;/span&gt;);
&lt;/pre&gt;&lt;br /&gt;
Why is it that it keeps sending the first chunk of &lt;b&gt;byte[]&lt;/b&gt;, and not what it reads new?</description>
      <author>JohnCodding</author>
      <link>https://www.codeproject.com/Messages/5964334/Sending-file-though-socket-as-byte</link>
      <pubDate>Tue, 26 Sep 2023 06:52:00 GMT</pubDate>
      <guid>3_5964334</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>[Solved] Getting and setting a File's all attributes</title>
      <description>I made an app (Windows only) with which you can create a backup of a folder/file locally or to a server. I'm done with the copy/restore process, but when it comes to restoring I have a small technical problem. If the file in originally hidden, then this is easy as you can call &lt;code&gt;Files.setAttribute(file.toPath(), "dos:hidden", true);&lt;/code&gt; which will make the file hidden on client side after it is created/restored, but there are files like &lt;code&gt;desktop.ini&lt;/code&gt; which aren't simply hidden but are system protected hidden and the above code will only give it the hidden status, and not system protected hidden.&lt;br /&gt;
&lt;br /&gt;
There is also &lt;code&gt;Files.getAttribute()&lt;/code&gt; but as the name suggests it only returns the attribute value for a single attribute, and not all of them to easily be able to do &lt;code&gt;Files.setAttributes(file.toPath(), Files.getAttributes(file.toPath()));&lt;/code&gt;. So my question is, is there a way to get a list will all the attributes a file has and then setting them in a more dynamically way and not having to call &lt;code&gt;Files.getAttribute();&lt;/code&gt; / &lt;code&gt;Files.setAttribute();&lt;/code&gt; for each of them line by line? If unfortunately there isn't one, and you do have to set them line by line, can someone give me a list with all the attributes for Windows OS like there is here for example with &lt;a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html"&gt;DateTimeFormatter&lt;/a&gt;[&lt;a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html" target="_blank"&gt;^&lt;/a&gt;] for pattern symbols?</description>
      <author>Valentinor</author>
      <link>https://www.codeproject.com/Messages/5964077/Solved-Getting-and-setting-a-Files-all-attributes</link>
      <pubDate>Mon, 25 Sep 2023 08:47:00 GMT</pubDate>
      <guid>3_5964077</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Getting  java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP</title>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
My Junit test cases are compiled and running fine with &lt;br /&gt;
&lt;br /&gt;
'zerocode-tdd',        version: '1.3.1' &lt;br /&gt;
'rest-assured',        version: '2.9.0'&lt;br /&gt;
'JAVA'                    version '1.8.0'   &lt;br /&gt;
'gradle'                  version '6.9.2   &lt;br /&gt;
&lt;br /&gt;
Now it is upgraded to &lt;br /&gt;
&lt;br /&gt;
'zerocode-tdd',        version: '1.3.33' &lt;br /&gt;
'rest-assured',        version: '5.3.0'&lt;br /&gt;
 'JAVA'                    version '1.11.0'   &lt;br /&gt;
'gradle'                  version '8.0.2&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
My test is compiled. while running getting below error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Test _mytest FAILED&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullPointerException&lt;br /&gt;
&lt;br /&gt;
snippet of code is myTest.java&lt;br /&gt;
&lt;br /&gt;
     &lt;a href="https://www.codeproject.com/Members/Test"&gt;@Test&lt;/a&gt; &lt;br /&gt;
     @JsonTestCase("zerocode/11_Test.zero")&lt;br /&gt;
     public void                  _11_Test() throws Exception {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Could you please suggest what is wrong.&lt;br /&gt;
Thanks in Advance</description>
      <author>Member 16085274</author>
      <link>https://www.codeproject.com/Messages/5960498/Getting-java-lang-RuntimeException-ZeroCode-Step-e</link>
      <pubDate>Mon, 04 Sep 2023 15:46:00 GMT</pubDate>
      <guid>3_5960498</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>What is the difference between a static and an instance variable in Java?</title>
      <description>&lt;div class='pre-lang' id='premain771107'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode771107' class='copy-code' data-index='771107' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre771107' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
What &lt;span class="code-keyword"&gt;is&lt;/span&gt; the difference between a &lt;span class="code-keyword"&gt;static&lt;/span&gt; and an instance variable &lt;span class="code-keyword"&gt;in&lt;/span&gt; Java?&lt;/pre&gt;</description>
      <author>Ashley OP</author>
      <link>https://www.codeproject.com/Messages/5955783/What-is-the-difference-between-a-static-and-an-ins</link>
      <pubDate>Tue, 08 Aug 2023 09:31:00 GMT</pubDate>
      <guid>3_5955783</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>JavaFX multithreading operation changing GUI elements</title>
      <description>I want to make it so that when the user launches the app, it will display the GUI but at the same time it will launch other threads (multithreading) that will do some calculations and when those are finished they will update some GUI elements (which are always created before the thread with calculations is launched, that is not a problem of getting null), also when a button is pressed same as before using multithreading it will do some calculation and update the GUI after each thread is done.&lt;br /&gt;
&lt;br /&gt;
Now the problem I have is that if you are using &lt;b&gt;Thread(new Runnable)/start();&lt;/b&gt; to launch multiple threads (even one) you get into the error &lt;code&gt;Not on FX application thread&lt;/code&gt;. As possible solutions I read about JavaFX &lt;b&gt;Task&lt;/b&gt; and &lt;b&gt;Service&lt;/b&gt; but those were freezing the GUI thread until they were done.&lt;br /&gt;
&lt;br /&gt;
This is what I tried ("&lt;b&gt;Functions.functionX&lt;/b&gt;" is the placeholder, the real function takes between 0-20 seconds to finish):&lt;br /&gt;
&lt;div class='pre-lang' id='premain325097'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode325097' class='copy-code' data-index='325097' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre325097' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
button.setOnAction(&lt;span class="code-keyword"&gt;event&lt;/span&gt; -&amp;gt; {
    Service&amp;lt;Void&amp;gt; doSomething = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Service&amp;lt;Void&amp;gt;() {
        @Override
        &lt;span class="code-keyword"&gt;protected&lt;/span&gt; Task&amp;lt;Void&amp;gt; createTask() {
            Functions.functionX(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;parameter"&lt;/span&gt;);
            &lt;span class="code-keyword"&gt;return&lt;/span&gt; &lt;span class="code-keyword"&gt;null&lt;/span&gt;;
        }
    };
    doSomething.start();
});
&lt;/pre&gt;&lt;br /&gt;
Now the problem with this is like I said, when the button is pressed, the GUI is unusable until the function finishes. Using straight &lt;b&gt;Task&lt;/b&gt; had the same effect unfortunately.&lt;br /&gt;
What do I need to change/add to make it so that I can launch multiple threads at a time, and inside them to change elements from GUI (right now I only want to update some Labels with .setText() inside those threads, each thread updates one Label)?</description>
      <author>JohnCodding</author>
      <link>https://www.codeproject.com/Messages/5953304/JavaFX-multithreading-operation-changing-GUI-eleme</link>
      <pubDate>Fri, 21 Jul 2023 16:37:00 GMT</pubDate>
      <guid>3_5953304</guid>
      <subject>Java</subject>
    </item>
    <item>
      <title>Operator precedence</title>
      <description>&lt;div class='pre-lang' id='premain839231'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode839231' class='copy-code' data-index='839231' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre839231' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
I am complete fresher at Java. Could You help me with https:&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;www.udemy.com/course/learn-java-to-master/learn/quiz/5933562#questions task, please?&lt;/span&gt;&lt;/pre&gt;</description>
      <author>darek29021988</author>
      <link>https://www.codeproject.com/Messages/5951770/Operator-precedence</link>
      <pubDate>Wed, 12 Jul 2023 15:41:00 GMT</pubDate>
      <guid>3_5951770</guid>
      <subject>Java</subject>
    </item>
  </channel>
</rss>