java

Drew Verlee 2024-01-16T03:56:08.410809Z

If i want to partition my lazy list into subsists by subsist size, i assume my options are a for loop which creates sublists based on the size of the current sublist compared against the max sub-list size or a stream which does the same only i have to likely write a custom accumulator or something. Should i just use a loop then? Is that a principle difference between the two abstractions or does it just seem simpler because i haven't written a custom accumulator before. For brevity (or possible as a distraction since i'm not sure i can enable this on my project), their are also https://download.java.net/java/early_access/jdk22/docs/api/java.base/java/util/stream/Gatherer.html which look like streaming "windows" to me.

2024-01-16T14:56:31.007099Z

Hey team, noob java question. My nephew asked me the following: His school computers are on java 1.8, which can't run the jar that he is building. Is there some tool that can "pre-package" whatever java runtime is needed for his jar?

dharrigan 2024-01-16T15:25:18.080099Z

Can you elaborate a bit more on what you mean by "cannot run the jar he is building"

dharrigan 2024-01-16T15:25:27.702139Z

How is he attempting to run it?

2024-01-16T15:33:14.929149Z

What he says: He goes to the school's windows computer, and double-clicks the jar file. I would imagine this just runs the equivalent of java -jar The reason he can't run it, paraphrased from his words: The UI Library he is using looks much worse when run with java 1.8. He also uses lambda expressions, which don't work in 1.8

dharrigan 2024-01-16T15:35:15.711609Z

I believe lambda's came in java 1.8

dharrigan 2024-01-16T15:35:40.871029Z

dharrigan 2024-01-16T15:36:31.440659Z

In terms of running it, it depends on what the OS is set to do on double click of the file. Is there any way he can open up a terminal/command prompt and do java -jar myjar.jar and see what the output is?

dharrigan 2024-01-16T15:37:09.481589Z

And what UI library is he using? (Re-reading your reply, it seems he can run it, otherwise, how would he know that the UI library looks worse?)

๐Ÿ‘ 1
2024-01-16T15:45:09.515679Z

Okay, I think he may have been a bit confused. He thought java 8 and java 1.8 were different versions. Looks like yes lambda expressions are supported, and FlatLaf (his UI library) supports java 8 too. I guess he had a previous project and developed some intuition that he hasn't tested. Thanks @dharrigan ๐Ÿ™‚ Will tell him to go to school and actually try running the jar

dharrigan 2024-01-16T15:46:09.775889Z

I'm happy to help and I hope he manages to succeed ๐Ÿ™‚

โค๏ธ 1
emccue 2024-01-16T17:45:39.861859Z

@stopachka separately the answer is yes

emccue 2024-01-16T17:46:02.806069Z

he can actually package his java code without a jar

emccue 2024-01-16T17:46:24.949379Z

give me a moment to make you an example project

emccue 2024-01-16T17:58:23.216009Z

emccue 2024-01-16T17:58:55.891419Z

this is using my [jresolve](https://github.com/bowbahdoe/jresolve-cli) tool + [just](https://github.com/casey/just)

emccue 2024-01-16T17:59:02.654539Z

but you can also just copy paste commands

emccue 2024-01-16T17:59:24.132169Z

but you can use jlink to make a special build of java that includes just their code

emccue 2024-01-16T17:59:33.443129Z

+ --launcher to add a file you can double click to run it

emccue 2024-01-16T17:59:56.634009Z

and you can do that for every OS without much hassle, just need to get the JMODS for mac, windows, etc.

emccue 2024-01-16T18:00:07.583649Z

and you can use jpackage to make a platform specific bundle

emccue 2024-01-16T18:00:39.399739Z

app-image would generally be the format to pick for windows (...i think) since then he won't need to run an installer

emccue 2024-01-16T18:00:46.496329Z

but also you could stop at the link step

emccue 2024-01-16T18:00:59.783699Z

and on mac, as i wrote it there, it produces a .app file

emccue 2024-01-16T18:02:39.956789Z

he can do this without modules too with --main-jar in jpackage

dharrigan 2024-01-16T18:02:41.624689Z

I think jlink is only available from 1.9 onwards

dharrigan 2024-01-16T18:02:49.942389Z

If he's on 1.8, he can't use that.

emccue 2024-01-16T18:02:55.092769Z

yes, but this bundles the java install with his code

emccue 2024-01-16T18:03:12.204499Z

so he doesn't have to be on 1.8

emccue 2024-01-16T18:03:32.691169Z

+ he can set --release 8 to make sure his code works if the teacher runs it

dharrigan 2024-01-16T18:03:43.702389Z

Interesting ๐Ÿ‘

emccue 2024-01-16T18:04:13.017339Z

a factoid that will maybe land harder with him - this is about how minecraft does it

emccue 2024-01-16T18:04:26.755999Z

minecraft used to require you install java separately, now it comes with java

dharrigan 2024-01-16T18:05:16.791919Z

man, it's years since I played minecraft. tbh. found it pretty boring...

emccue 2024-01-16T18:05:37.424849Z

thats horrifying, but whatever

dharrigan 2024-01-16T18:05:45.228509Z

๐Ÿ™‚

emccue 2024-01-16T18:06:06.546939Z

do you have his photo editor project's code?

โค๏ธ 1
emccue 2024-01-16T18:07:18.278169Z

this approach can get kneecapped by a strange dependency - flatlaf is fine, but you need to do different stuff if you have a non-modular dep

2024-01-16T20:31:34.965969Z

This is awesome! Thanks team. TIL many things todayโ€”one of the benefits of a curious nephew. I donโ€™t have his code but if he runs into problems will let you know @emccue !

๐Ÿ‘ 1