How to show class file (not java file) in explorer in IDEA? When I select a java file, I want to position it in the explorer, I know in Eclipse it is easy, but what I should do in IDEA?
-
1Please clarify what problem you are trying to solve. Do you want IDE to navigate you to the `.class` file containing the bytecode for the corresponding `.java` file you have open in the editor? Do you want IDE to open the folder with the `.class` file in the Windows Explorer? What for? – CrazyCoder Jun 25 '19 at 02:49
-
Yes, please clarify what do you want to do. If you have only `.java` file, the `.class` file may not yet exist if it wasn't compiled (or the target build directory was cleaned up afterwards). What I can suggest you're really asking is to show the same `.java` or any other file in operation system explorer. To do this, right-click on the file and select "Show in Explorer" context menu point. – Dmitriy Popov Jun 25 '19 at 22:42
-
I want IDE to open the folder with the .class file in the Windows Explorer – steven Jun 27 '19 at 03:00
-
Using Eclipse to navigate the .class file within Windows/Macbook https://www.cnblogs.com/stevenlii/p/8513410.html – steven Jun 28 '19 at 12:09
1 Answers
You can do it with the External Tool like this:
This answer describes what parameters to use for the explorer.exe
to select the file.
Using IntelliJ IDEA macros the Arguments field will look like this:
/select,"$OutputPath$\$FileDirRelativeToSourcepath$\$FileNameWithoutExtension$.class"
It will open Explorer with the output file selected:
For the source file located in C:\work\attaches\hotswap-bug\src\foo\bazz\Another.java
the tool will select C:\work\attaches\hotswap-bug\out\production\hotswap-bug\foo\bazz\Another.class
file.
This tool can be invoked from the editor right click menu while inside the source .java
file:
You can also assign a keyboard shortcut to this tool or make an action in the toolbar for easier access.
Final result:
Just curious, what's the real world use case for this?

- 389,263
- 172
- 990
- 904
-
Thank you very much. It works!. I also have a MacBook, but I don't know how to set it too. Could you help me? – steven Jun 28 '19 at 12:03
-
1@steven I don't have Mac, sorry, but you can [try this](https://stackoverflow.com/a/51186186/104891). – CrazyCoder Jun 28 '19 at 17:25