#Jachar: Zero-dependency Java 21 Text Editor

141 messages · Page 1 of 1 (latest)

round merlin
#

Hello everyone,

I recently completed the visual iteration of Jachar, a lightweight text editor built with Java 21 using zero external dependencies.

Repository: https://github.com/Bri-idk/Jachar

Current Focus:
I tried to keep the architecture clean by decoupling the persistence layer (FileManager) from the display and rendering layer (WindowManager).

Questions for review:

What are your thoughts on the current separation between disk operations and the GUI?

What is the idiomatic way to structure file and buffer state in Java (tracking dirty state, cursors, line offsets, etc.) to keep it extensible?

Are there any Java 21 features or patterns I could leverage better here to make the design more robust?

Appreciate any pointers, code review, or advice!

GitHub

Jachar is an open-source, lightweight text editor written in Java. Created as a hands-on initiative to master Java fundamentals and object-oriented programming, this project is designed with scalab...

ripe timberBOT
#

<@&987246883653156906> please have a look, thanks.

round merlin
quasi edge
#

thank god its not an ai thing - reading your code now

#

at least the code is yours, but write your own readmes

dusky cave
#
public class WindowManager {
    //* Elementos globales
    public static Path currentPath = null;
    private static JFrame window;
    private static JTextArea area;
    private static boolean isDark = false;
    private static JButton btnOpenFile, btnNewFile, btnSave, btnTheme;
    private static JPanel panel;

Don't abuse static, use objects

    public static void createWindow(){
        try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }catch (Exception e){
        }

Don't hide exceptions, handle them

public class FileManager {
    public static boolean writer(Path location, String text){
        /*!Estructura necesaria para poder usar archivos de la maquina en Java, writer seria nuestro item con los metodos dentro, la estructura de Files necesita de un parametro PATH (literalmente unpath donde trabajar). Un Charset (este caso uso UTF-8). Y metodos Standar para cuando se abre o se usa el metodo (ejemplo: CREATE -> crea el archivo si no existe, APPEND -> incerta el contenido al archivo existente). Files necesita estar en un try ya que es necesaria la recoleccion del error en caso de no poder abri el archivo
         */
        try {
            Files.writeString(location, text);
            return true;
        } catch (IOException e) {
            return false;
        }
    }

    public static String reader(Path location){
        try  {
            return Files.readString(location);
        } catch (IOException e) {
            return "Error: " + e;
        }
    }
}

At least you are not technically hiding exception here but still, you might want to improve handling or at least print them to the console here
Also why do you return the exception in reader as the reading string ????
And finally, this class and those methods seem a bit useless

Ah and stop abusing comments please, a lot is redundant

#

@round merlin

round merlin
#

Im sorry if that is bad, im going to make a readme by my self when i get a little bit further with the project

quasi edge
#

kinda the point of writing is communication

#

if you aren't actually writing it to communicate with an audience its always going to be hard to make a readme

#

like an easy readme would be what you did here - "hey guys this is my project looking for feedback"

round merlin
quasi edge
#

but you'd have to decide that that sort of audience is what you are writing for

quasi edge
round merlin
quasi edge
round merlin
#

I feel kinda dumb because i think java its okey but for a project like this idk, doesn’t seem really optimal

#

Im sorry about my English, if i say something that’s not right or something pls say it to me

quasi edge
#

The program actually looks pretty nice

#

I cant read Spanish so idk what it says though

#

maybe localization would be a fun thing to learn about

round merlin
#

Yeah, I thought the same xD. My comments are in spanish too, so I might change the variable names and comments in the code

#

Oh important thing i got this, GEMINI.md, but im using it only for the readmes and some research, im not vibe coding this XD

green dawn
#

can you open 2 editor at the same time?

round merlin
green dawn
round merlin
#

i have an idea

#

you can modify them everywhere and for testing classes alone that make it impossible

#

thats what i know now

#

now i feel kinda confused, i have to refactor my code ?

#

i thought that using like POO was making it to complex for the thing i was doing

round merlin
green dawn
#

another thing you did is making every methods public in your classes

round merlin
round merlin
#

It confuses me a little

green dawn
#

just start by making everything private and non static, then only put public what you need

#

it is important as it will make you learn to use objects and scope

round merlin
#

Like the instance for the creteWindow function ?

green dawn
#

right now you kinda think globally

#

it work because you only have 4 files

#

what will you do when you are in 2000 files

#

you can't think globally anymore

#

that is why we do not code in a way that is global

round merlin
#

But how can i like think on modules instead of a global program?

green dawn
#

we focus our attention to a small part

#

well you do not have enough code to start thinking in module

round merlin
#

But how i like think and make that small parts? How i know how small or how big it has to be?

green dawn
#

right now you kinda only need 1 module

#

when you start to search for code it is time to create module by moving files to separate directories

round merlin
#

Okey, like my src directory right?

green dawn
#

the project evolve over time

#

it is not a one time deal

#

src is all global

round merlin
#

Alright, so, i got to stop thinking that my code is going to work forever

green dawn
#

in src you need a main package

round merlin
green dawn
#

your project package for your entity

green dawn
#

it does not mean that the program behind that api cannot change, just that the api do not change

round merlin
#

Okey i get it, thaks! Im i was struggling with the idea of refactoring everything but now i want to make it better

green dawn
#

example I got 60+ java project, when I make packages, I reserve a package name for the project that is unique in all my projects

#

that way, I can use code from other projects

round merlin
#

It is ahh

green dawn
#

it could be

#

anything you can imagine

round merlin
#

I dont know the word sorry

#

My english is pretty limited

green dawn
#

this is the thing with programming, you are free to do anything, so at first you may be lost

round merlin
#

It is actually the problem with freedom I guess

#

But thanks man you changed my mind about software development

green dawn
#

really? is it for the better?

round merlin
#

Yeah

#

I was scared

green dawn
#

peepo_heart cool

round merlin
#

Actually every comment on this forum help me i was scared about joining on a developers community

green dawn
#

what were your fears?

round merlin
#

But you all helped me, thanks all, fr i feel better now about every thing

round merlin
#

Matching a hard world to enter and get accepted

#

I mean is this kind of stuff that you overthink about and when you try it isn’t how you thought

green dawn
#

yes

round merlin
#

So, tank you for your time, you really help me

green dawn
#

btw, I do not see anywhere how you compile and build your exe

round merlin
#

For the jar i use inteliG with the artifacts builder

green dawn
round merlin
#

So it is simple but for the exe i use the java sdk util for doing that , with the powershell i use a command to do it

#

I am on a arm laptop so i have a setup a little bit weird

#

I use windows only for making the exe

#

But wsl with debian

green dawn
#

window arm?

round merlin
#

For developing

round merlin
green dawn
#

humm, does it not cause problem for the exe?

round merlin
#

Sometimes it makes me slow because i got to find specific binaries for my laptop

green dawn
#

is that exe only for arm?

round merlin
#

For compiling

green dawn
#

yeah, but for the exe part

round merlin
#

So when i make the exe it save a little from that vm and doesn’t make it for arm

green dawn
#

I see

round merlin
#

You want to se the command?

#

Maybe im making it wrong

#

But all of you use it and didn’t have problems

green dawn
#

no, but in an ideal world you would want github to build your releases

#

that way, it could use vm for each target os and arch

round merlin
#

I dont feel comfortable if i dont do it a least one time

green dawn
#

btw know not now

#

are you refactoring it right now?

round merlin
#

So thats why i make it that way but from now i will start using the GitHub util

#

Thats for asking

quasi edge
green dawn
#

you can make a bin directory in your project btw, and make terminal script for each command you do.

#

that way, when you come back on an old project 6 months later, you are not lost

round merlin
# quasi edge i do

& "C:\Program Files\Java\jdk-26\bin\jpackage.exe" --name "Jachar" --input "out\artifacts\Jachar_jar" --main-jar "Jachar.jar" --main-class "Main" --type app-image --dest "$HOME\Desktop\Jachar_Build"

#

the last part is the destiny OUT out my wsl cause its for windows and making it inside de wsl kills my computer for som reason

quasi edge
#

lots of ways to do that

#

but if you are already using powershell, just make .ps1 files

round merlin
round merlin
quasi edge
#

basically

round merlin
#

i use bats for dumb things like join to zoom calls

#

cause im lazy

green dawn
#

btw, using swing, you can have the normal menu bar

#

and status bar

round merlin
green dawn
#

JMenuBar

round merlin
#

Im trying it today next version will have that

#

Its better than my JPanel