June 28, 2023
I am using the Intellij IDEA community edition IDE.
Here is a decent 5 minute video from 2020 that explains how this all can be done:
It gives a dialog that wants you to specify a Main Class. This is the class wherein it should find your main method. In my case I just have main() at the top level. The game for that is to specify "projectKt" as the main class if your code is in project.kt. In my case I will use MainKt since my code is in Main.kt. Then click the "OK" button for the dialog. Another window shows the generated artifact and you click "OK" to dismiss that as well.
Now at the top of the GUI (the tool bar?) select Build, then Build Artifacts from the pulldown menu. It shows me "bell.jar" and that is what I want.
Now you have to find bell.jar on your filesystem. In my case it is at:
cd /u1/home/tom/IdeaProjects/bell/out/artifacts/bell_jar java -jar bell.jarAnd it works!. I see:
java -jar bell.jar Hello socket Socket[addr=/192.168.0.41,port=1013,localport=54106] Client sending [bell] Client receiving [OK]And it rings the bell in my workshop.
This means I know how to generate projects that anyone with java installed (the JRE anyway) can run.
As for why the IDEA ide calls a .jar file an artifact -- it is far beyond me to say.
Adventures in Computing / [email protected]