damn/gdl

[Linux] Syntax error (ClassNotFoundException) compiling at (gdx/mac_dock_icon.clj:1:1).\ncom.apple.eawt.Application

Closed this issue · 15 comments

wodin commented

I tried out the Hello World app on Linux and got the above error.

So this comment seems to be correct:
; TODO if this is required on windows/linux will break?

damn commented

Thanks for the input!

By the way if you call lein dev you start a 'dev-loop'. You can close the app window and all namespaces will be reloaded with clojure.tools.namespace.repl/refresh-all.

There is also a function gdl.dev-loop/restart! to restart in case of errors or even if the app does not start up. In this way you don't have to restart the JVM everytime.

I will add this to the README

damn commented

Fixed in 93f0a86

Please try it again! I do not have linux.

wodin commented

Thanks. I tried removing ~/.m2/repository/com/github/damn/ but I got the same error, so I suppose it's not fetching the updated version. How might I specify the main branch in the dependencies?

damn commented

See here: https://jitpack.io/#damn/gdx, you can specify each commit also.

[com.github.damn/gdx "main-SNAPSHOT"]

damn commented

Oh I got confused myself from the renaming, (but I will probably rename it back to gdx because this is just a libgdx wrapper )
This is the correct dependency:
https://jitpack.io/#damn/gdl/main-SNAPSHOT

[com.github.damn/gdl "main-SNAPSHOT"]

Note that I will change it back to gdx in the next days.

wodin commented

hmmm... I'm not having much luck:

I tried with both this:

  :repositories [["jitpack" "https://jitpack.io"]]
  :dependencies [[org.clojure/clojure "1.10.3"]
                 [com.github.damn/gdl "main-SNAPSHOT"]]

and this:

  :repositories [["jitpack" "https://jitpack.io"]]
  :dependencies [[org.clojure/clojure "1.10.3"]
                 [com.github.damn/gdx "main-SNAPSHOT"]]
$ lein deps :tree
Could not find artifact com.github.damn:gdl:jar:main-SNAPSHOT in clojars (https://repo.clojars.org/)
Could not find artifact com.github.damn:gdl:jar:main-SNAPSHOT in jitpack (https://jitpack.io)
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
$ lein deps :tree
Could not find artifact com.github.damn:gdx:jar:main-SNAPSHOT in clojars (https://repo.clojars.org/)
Could not find artifact com.github.damn:gdx:jar:main-SNAPSHOT in jitpack (https://jitpack.io)
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
damn commented

It didnt built because there was one more mac-specific setting in project.clj

This is fixed now and you can also use [com.github.damn/gdl "main-SNAPSHOT"] now. Please try again.

wodin commented

OK, it's finding it now. But if I try to run the Hello World app, I get:

Execution error (FileNotFoundException) at clj-game.core/eval157$loading (core.clj:1).
Could not locate gdx/app__init.class, gdx/app.clj or gdx/app.cljc on classpath.

Tried replacing gdx with gdl, but that resulted in:

Syntax error compiling at (clj_game/core.clj:18:3).
No such var: app/create
damn commented

Can you try please just lein dev. It should start the test/gdl/simple_test.clj.

wodin commented

Yes, that works.
What I was trying was:

lein new app blah
Then cd blah, add the repository and dependency to project.clj and edit src/blah/core.clj to look like this (except for the ns):

gdl/README.md

Lines 34 to 58 in 7fd5cf8

(ns hello-world.core
(:require [gdx.app :as app]
[gdx.game :as game]
[gdx.graphics :as g]))
(def main-screen
{:show (fn [])
:render (fn [] (g/render-gui ; takes care of all graphics context initializations
(fn []
;; your render code here
)))
:update (fn [delta] ; delta is elapsed time in ms since last update
;; your update code here
)
:destroy (fn [])})
(defn app []
(app/create (game/create {:main main-screen})
{:title "Hello World!"
:width 800
:height 600
:full-screen false}))
(defn -main []
(app))

Followed by lein run

Should that not work?

wodin commented

Anyway, the initial problem is solved, so you can close this issue if you like.

damn commented

I just updated the readme in order to start a new app with gdl as dependency. ( [com.github.damn/gdl "main-SNAPSHOT"])

(ns hello-world.core
  (:require [gdl.backends.lwjgl3 :as lwjgl3]
            [gdl.game :as game]
            [gdl.graphics :as g]))

(def main-screen
  {:show (fn [])
   :render (fn [] (g/render-gui ; takes care of all graphics context initializations
                    (fn []
                      ;; your render code here
                      )))
   :update (fn [delta] ; delta is elapsed time in ms since last update
            ;; your update code here
            )
   :destroy (fn [])})

(defn -main []
  (lwjgl3/create-app (game/create {:main main-screen})
                     {:title "Hello World!"
                      :width 800
                      :height 600
                      :full-screen false}))

Can you try it please?

wodin commented

Tried it. Unfortunately I get other errors.

Linux:

$ lein run
Execution error (ClassCastException) at gdl.graphics/load-state (graphics.clj:50).
class clojure.lang.Var$Unbound cannot be cast to class java.lang.Number (clojure.lang.Var$Unbound is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')

Full report at:
/tmp/clojure-4762244695721192393.edn

macOS:

% lein run
Execution error (IllegalStateException) at org.lwjgl.glfw.EventLoop/check (EventLoop.java:33).
GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.

Full report at:
/var/folders/kj/rwm7htb51n18wlz4pbljb75w0000gn/T/clojure-15243725444493280243.edn

If you want the "full reports", let me know.

damn commented

Oh I introduced this bug yesterday. Should be fixed now in 4cce7bf.

Please use lein dev, not lein run.

The error for Mac is mentioned in the Readme and in the error message, you need to set this:

export JVM_OPTS=-XstartOnFirstThread
wodin commented

Oh I introduced this bug yesterday. Should be fixed now in 4cce7bf.

Thanks, it works now.

Please use lein dev, not lein run.

No, I was doing this:

lein new app blah
cd blah
# edit project.clj to add the repository and dependency
# edit src/blah/core.clj to add the Hello World source code, except keep the `blah.core` namespace.
lein run

This works now. i.e. it creates a black window with a title of "Hello World!".