#3412·micro

Micro places compiled Java programs into incorrect directory when auto-compiling

Author: ItzARubixCreated Aug 1, 2024Updated Sep 10, 2026
Labelsplugin

Description of the problem or steps to reproduce

Upon saving any Java program that throws no compiler errors, Micro will automatically compile and save a .class file with the same name as the .java file that was saved. However, when certain .java programs are saved as part of a package, Micro will place the compiled file in the wrong directory.

To reproduce:

  1. Create a directory to serve as your project source. I'm using ~/Documents/JavaProjects/ProjectSource, but you can use anything, and I'll just refer to this as src from now on.
  2. Create a folder such as src/MyPackage.
  3. Navigate to src/MyPackage and, using Micro, create a file such as src/MyPackage/PackagedClass.java. The class should include package MyPackage; as the first line, and the contents can probably be anything, as long as the result is a valid Java class. Upon saving, notice that Micro has taken the liberty of creating a new directory, src/MyPackage/MyPackage, and within this new directory, the compiled .class file can be found, src/MyPackage/MyPackage/PackagedClass.class. This is the crux of the issue. When correctly compiled, the resulting compiled class should be found in the same directory as the original .java file. (The reason this is an issue is because a developer may wish to structure their .java files in accordance with their package structure, and so having Micro create the compiled .class files in the wrong directory creates hassle and confusion).

I've also been able to create situations where a .java file in the default package causes the same issue on a much larger scale. For example, I had a situation where I had a file in /home/[User]/Documents/JavaProjects/TestCore/Test.java that, when saved after being edited with Micro, created a class in /home/[User]/Documents/JavaProjects/TestCore/home/[User]/Documents/JavaProjects/TestCore/Test.class, and I have... no idea how or why this happens. I'm not able to consistently reproduce it, with some projects it happens and with some it doesn't

I apologize if I have made any errors in my explanation, and please let me know if there is anything I should clarify or change.

Specifications

Commit hash: 68d88b57 OS: Linux Terminal: Konsole (KDE's Terminal Emulator)