Fork me on GitHub
#tools-deps
<
2023-03-10
>
aaelony01:03:52

I have an uberjar that runs fine on my mac, e.g.:

java -cp target/query.jar clojure.main -m aegp.main --help
works fine on my mac. Relevant part of the deps.edn file is:
:uberdeps {
             :replace-deps {uberdeps/uberdeps {:mvn/version "1.2.0"}}
             :replace-paths []
             :main-opts ["-m" "uberdeps.uberjar"]
             }
all my *.clj source files have (:require [...] (:gen-class)), yet a colleague running windows with only a JRE (not JDK) gets:
Error: Could not find or load main class clojure.main
though when he runs it from windows. is there a better more robust manner to create the uberjar such that it can run on any of windows, macos, linux?

hiredman01:03:41

Do you know the command line your colleague is using?

hiredman02:03:36

That is exactly the error message you would expect if they tried that with a regular jar of your project, not an uberjar, so make sure they are using an uberjar

Alex Miller (Clojure team)02:03:34

that error indicates the clojure.main class is not in the uber jar. if not, then your first command wouldn't work anywhere so something doesn't add up. you might check jar tf target/query.jar | grep clojure/main

aaelony02:03:22

cool, thanks. I'll check with him what he ran exactly. I'm also converting to a lein project to see if lein uberjar works as well..

hiredman02:03:03

I would not bother with that

hiredman02:03:42

If you can run it, but they cannot, the very likely explanation is they are running something different

aaelony02:03:57

in anycase would be nice to do it correctly (on my end) if I am missing something

hiredman02:03:09

If the uberjar worked for you then it is unlikely there is anything wrong with it

aaelony02:03:21

yeah - works perfectly for me

aaelony02:03:06

could the version of java he is using be material? I am using 17, I think he is using java 8

hiredman02:03:02

Are you building the uberjar and sending it to them or are they building it for themselves?

aaelony02:03:27

embarassingly, I'm slacking him a jar file

aaelony02:03:38

(that I built)

hiredman02:03:18

Then double check and make sure it is the uberjar and not a regular jar

👍 2
hiredman02:03:35

Make sure it is the most recent one

aaelony02:03:27

he left for the evening. I'll check with him tmrw. Thanks for the responses

hiredman02:03:34

Make sure they aren't mixing -cp and -jar flags. They are mutually exclusive, but I forget if you get an error or the java just silently ignores one or the other

🔥 2