[SOLVED] how to find the .class file after running a .java project on vscode for macOS?

Issue

This Content is from Stack Overflow. Question asked by Besen

I’m trying to find the .class file after running a java project in VScode on macOS, I searched google but there is only path for windows OS, can anyone help to figure out the .class file?
This is the java project’s name :testSearch.java

I want to find the testSearch.class file after running.



Solution

Explanation

By default, VSCode outputs ‘.class’ files into different locations depending on the type of file you’re working with:-

  1. If you run a single ‘.java’ file, it’ll output the ‘.class’ file into a path that looks like this: /private/var/folders/ys/rgjr_wyd0d715dz546hydfrr0000gn/T/vscodesws_6d2aa/jdt_ws/jdt.ls-java-project/bin
    enter image description here

  2. If you open a folder that contains ‘.java’ files and run them, the ‘.class’ files will be inside of a path that looks like this: /Users/YourUserNameHere/Library/Application Support/Code/User/workspaceStorage/e358195aec7543686cb2440051c91f82/redhat.java/jdt_ws/SplayTree Project_d551e7d6/bin
    enter image description here


Solutions

  1. To find the output path for your own project, just look for it inside VSCode’s terminal after running.

  2. To change the default output directory for compiled ‘.class’ files:
    Go to VSCode settings -> Search for "java project output path" -> Click on "Edit in settings.json" -> Add the desired path inside the quotation marks (Note: this will only work with Workspace projects. It won’t work with Maven/Gradle).

enter image description here
enter image description here


This Question was asked in StackOverflow by Besen and Answered by Ahmad Mtera It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?