Open a File in default File explorer and highlight it using JavaFX or plain Java
<p>I wish to do what the title says.</p>
<hr />
<p><strong>Part Solution:</strong></p>
<p>For example in <code>Windows</code> you can use the code below to open a file in the default explorer and highlight it.</p>
<p>(<code>although it needs modification for files containing spaces</code>):</p>
<pre class="lang-java prettyprint-override"><code>/**
 * Opens the file with the System default file explorer.
 *
 * @param path the path
 */
public static void openFileLocation(String path) {
    if (InfoTool.osName.toLowerCase().contains(&quot;win&quot;)) {
        try {
            Runtime.getRuntime().exec(&quot;explorer.exe /select,&quot; + path);
        } catch (IOException ex) {
            Main.logger.log(Level.WARNING, ex.getMessage(), ex);
        }
    }
}
</code></pre>
<hr />
<p><strong>Useful Links:</strong></p>
<p>Links which are similar but <code>no way dublicates</code> or not answered:</p>
<p><a href="https://stackoverflow.com/questions/7357969/how-to-use-java-code-to-open-windows-file-explorer-and-highlight-the-specified-f#7369564">How to use java code to open Windows file explorer and highlight the specified file?</a></p>
<p><a href="https://stackoverflow.com/questions/15875295/open-a-folder-in-explorer-using-java">Open a folder in explorer using Java</a></p>
<p><a href="https://stackoverflow.com/questions/16604341/how-can-i-open-the-default-system-browser-from-a-java-fx-application#16615384">How can I open the default system browser from a java fx application?</a></p>
<hr />
<p><strong>More explanation:</strong></p>
<ul>
<li><p>Is there a way to do it using JavaFX ?</p>
<pre><code>  If not at least i need a link or some way to make the app system  
   independence.I mean i don't know the default explorer for every OS     
   that the application is going to work , i need a link or help doing that.
</code></pre>
</li>
<li><p>Do i need to write a ton of code to do this?</p>
</li>
<li><p>Is out there any library for doing that?</p>
</li>
<li><p>Do Java9 support that?</p>
</li>
</ul>
<hr />
<p><strong>Finally:</strong></p>
<p>It is very strange that for so common things i can't find answers and libraries .</p>
<hr />
<p>Example of highlighted or selected in Windows 10:</p>
<p><a href="https://i.stack.imgur.com/P8d4D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P8d4D.png" alt="enter image description here" /></a></p>