Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+19 votes

I am trying to figure out how to open up the file explorer in multiple platforms on eclipse. I can open it in windows, but not in Mac or linux. Does anybody have any good resources for this?

asked in CSC305 Fall 2022 by (1 point)
+4

Can you explain more about what you are wanting to achieve and why?

Are you trying to open a folder view from Java code? If so, why? If you want the user to select a file, look at the JavaFX FileChooser stuff.

If you really want to open an external program for the user to explore a folder, here are some tips, though not a complete answer:

On Mac, I believe the Windows Explorer equivalent is called "finder", and on Linux it varies based on the Desktop environment, although the command xdg-open folder-path will probably work on most systems.

2 Answers

+6 votes

While I haven't worked with this in operating systems other than Windows, I think it's done the same way, by creating a new FileChooser object. The documentation states that it opens "a file explorer on the user's computer" which makes me think it adapts to any OS.

answered by (1 point)
+4 votes

I have found this resource that explains how you can open file explorer in multiple platforms on exclipse using MacOS. Here is the link below,
https://genuinecoder.com/how-to-open-file-explorer-in-java/#:~:text=Opening file explorer with java in any platform,explorer when the given file is a directory.
Hope that helps.

answered by (1 point)
...