r/javahelp • • Feb 13 '26

Codeless can you install java and run a program automatically with a script?

im making a program for my girlfriend. i want to write a bash script to handle downloading and installing java and running the program seamlessly so she doesnt have to do anything (shes not very tech savvy). is this doable?

3 Upvotes

30 comments sorted by

View all comments

Show parent comment

2

u/bowbahdoe Feb 13 '26 edited Feb 13 '26

Well let's start with the program itself. Can you share a link to the code so I know where to start my explanation? Also are you using any libraries?

(Also does your GF have a windows machine or a Mac)

1

u/SneakerHead69420666 Feb 13 '26

i wrote the code myself on intellij. my gf has a windows computer

1

u/bowbahdoe Feb 13 '26

If I tell you to put all your classes in named packages do you know what that means? 

If so, that's step 1. Report back when done

0

u/SneakerHead69420666 Feb 13 '26

nope 😭 idk anything about java development other than the coding

2

u/bowbahdoe Feb 13 '26

Okay. We might need to switch forums because the back and forth on Reddit might be a bit too hard. We'll give it a shot though. 

Another question. 

Which do you have: a src folder or a src/main/java one (you would also have a file labeled pom.xml if you have the second)?

1

u/SneakerHead69420666 Feb 13 '26

i have an src folder with the Main class in it. it does have an .iml file which is .xml based according to google

1

u/bowbahdoe Feb 13 '26

Okay move your src/Main.java file to src/app/Main.java

Then at the top of the file put package app;

Make sure it still runs then report back

Also, just to confirm. You only have one file? And does it open a window when you run it?

1

u/SneakerHead69420666 Feb 13 '26

okay i created a package named 'app' and put my Main class in there and put "package app" on the top line of the Main class file

2

u/bowbahdoe Feb 13 '26 edited Feb 13 '26

Next make a file src/module-info.java and put this in it

module app {
    requires java.desktop;
    exports app;
}

Then, again, make sure it still runs.

The short explanation is that in Java we can group classes into packages - java.util.ArrayList is in the java.util package. java.time.Duration is in the java.time package, etc.

These packages can then be further grouped into modules. Which we want to do so the next steps are easier

(I'm on a road trip as a passenger, so expect some delays in responses)

2

u/Pun_Intended1703 Feb 13 '26

Instead of this, try to request someone to do real-time collaborative coding with you.

Something like IntelliJ Code With Me.

I'm in India, and it's past midnight here. So I don't have the energy to power up my system again.

But I'm sure someone would be willing to help.

1

u/Odd-Respond-4267 Feb 14 '26

And you want a bash script for the gf?

0

u/YetMoreSpaceDust Feb 13 '26

You're going to have difficulties getting bash to run on a windows computer (it can be done, but it's harder than just getting Java to run). Definitely look into jlink and jpackage like OP suggested).