quil / quil

Main repo. Quil source code.
Eclipse Public License 1.0
2.96k stars 164 forks source link

ClassNotFoundException thrown when running new quil sketch #353

Open naturalbornchiller opened 3 years ago

naturalbornchiller commented 3 years ago

I'm excited to use Quil but I've hit a roadblock.

Upon creating a new quil using lein new quil my-stuff and running lein run in terminal, I'm getting this error:

{:clojure.main/message
 "Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:581).\ncom.apple.eawt.QuitHandler\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.ClassNotFoundException,
  :clojure.error/line 581,
  :clojure.error/cause "com.apple.eawt.QuitHandler",
  :clojure.error/symbol
  jdk.internal.loader.BuiltinClassLoader/loadClass,
  :clojure.error/source "BuiltinClassLoader.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message "Syntax error macroexpanding at (core.clj:36:1).",
    :data
    {:clojure.error/phase :execution,
     :clojure.error/line 36,
     :clojure.error/column 1,
     :clojure.error/source "core.clj"},
    :at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3707]}
   {:type java.lang.NoClassDefFoundError,
    :message "com/apple/eawt/QuitHandler",
    :at [java.lang.Class getDeclaredMethods0 "Class.java" -2]}
   {:type java.lang.ClassNotFoundException,
    :message "com.apple.eawt.QuitHandler",
    :at
    [jdk.internal.loader.BuiltinClassLoader
     loadClass
     "BuiltinClassLoader.java"
     581]}],
  :trace
  [[jdk.internal.loader.BuiltinClassLoader
    loadClass
    "BuiltinClassLoader.java"
    581]
   [jdk.internal.loader.ClassLoaders$AppClassLoader
    loadClass
    "ClassLoaders.java"
    178]
   [java.lang.ClassLoader loadClass "ClassLoader.java" 522]
   [java.lang.Class getDeclaredMethods0 "Class.java" -2]
   [java.lang.Class privateGetDeclaredMethods "Class.java" 3166]
   [java.lang.Class getMethodsRecursive "Class.java" 3307]
   [java.lang.Class getMethod0 "Class.java" 3293]
   [java.lang.Class getMethod "Class.java" 2106]
   [processing.core.PApplet runSketch "PApplet.java" 10855]
   [quil.applet$applet_run invokeStatic "applet.clj" 82]
   [quil.applet$applet_run invoke "applet.clj" 79]
   [quil.applet$applet invokeStatic "applet.clj" 330]
   [quil.applet$applet doInvoke "applet.clj" 270]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3702]
   [clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
   [clojure.lang.Compiler eval "Compiler.java" 7182]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$load_one invoke "core.clj" 5903]
   [clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
   [clojure.core$load_lib invokeStatic "core.clj" 5947]
   [clojure.core$load_lib doInvoke "core.clj" 5928]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$load_libs invokeStatic "core.clj" 5985]
   [clojure.core$load_libs doInvoke "core.clj" 5969]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$require invokeStatic "core.clj" 6007]
   [clojure.core$require doInvoke "core.clj" 6007]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [user$eval140$fn__144 invoke "form-init10943135600777807971.clj" 1]
   [user$eval140 invokeStatic "form-init10943135600777807971.clj" 1]
   [user$eval140 invoke "form-init10943135600777807971.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.Compiler loadFile "Compiler.java" 7574]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "com.apple.eawt.QuitHandler",
  :phase :execution}}

I haven't changed anything within the project other than my project.clj to include :main my-stuff.core

My specs are: macos (big sur) openjdk 11.0.12 clojure 1.10.1 leiningen 2.9.6 quil 3.1.0 processing 3.5.4

Would love someone's help troubleshooting, I'm new to java and clojure and may well be overlooking something.

TMiller00 commented 3 years ago

Per this, you should be using quil "4.0.0-SNAPSHOT" if you're using Java 11.

naturalbornchiller commented 3 years ago

Got it. Now I've switched to Java 8 and am getting a different error.

{:clojure.main/message
 "Syntax error compiling at (/private/var/folders/3j/m7d3v4b116768h50xt6m4stw0000gn/T/form-init3264948636380199103.clj:1:125).\nCannot find anything to run for: my-stuff.core\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 1,
  :clojure.error/column 125,
  :clojure.error/source "form-init3264948636380199103.clj",
  :clojure.error/path
  "/private/var/folders/3j/m7d3v4b116768h50xt6m4stw0000gn/T/form-init3264948636380199103.clj",
  :clojure.error/class java.lang.Exception,
  :clojure.error/cause
  "Cannot find anything to run for: my-stuff.core"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (/private/var/folders/3j/m7d3v4b116768h50xt6m4stw0000gn/T/form-init3264948636380199103.clj:1:125).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 1,
     :clojure.error/column 125,
     :clojure.error/source
     "/private/var/folders/3j/m7d3v4b116768h50xt6m4stw0000gn/T/form-init3264948636380199103.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7648]}
   {:type java.lang.Exception,
    :message "Cannot find anything to run for: my-stuff.core",
    :at
    [user$eval140 invokeStatic "form-init3264948636380199103.clj" 1]}],
  :trace
  [[user$eval140 invokeStatic "form-init3264948636380199103.clj" 1]
   [user$eval140 invoke "form-init3264948636380199103.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.Compiler loadFile "Compiler.java" 7574]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "Cannot find anything to run for: my-stuff.core",
  :phase :compile-syntax-check}}

Is this because I don't have a -main function in my-stuff.core?

naturalbornchiller commented 3 years ago

I haven't changed my-stuff.core since scaffolding the project and it looks like this:

(ns my-stuff.core
  (:require [quil.core :as q]
            [quil.middleware :as m]))

(defn setup []
  ; Set frame rate to 30 frames per second.
  (q/frame-rate 30)
  ; Set color mode to HSB (HSV) instead of default RGB.
  (q/color-mode :hsb)
  ; setup function returns initial state. It contains
  ; circle color and position.
  {:color 0
   :angle 0})

(defn update-state [state]
  ; Update sketch state by changing circle color and position.
  {:color (mod (+ (:color state) 0.7) 255)
   :angle (+ (:angle state) 0.1)})

(defn draw-state [state]
  ; Clear the sketch by filling it with light-grey color.
  (q/background 240)
  ; Set circle color.
  (q/fill (:color state) 255 255)
  ; Calculate x and y coordinates of the circle.
  (let [angle (:angle state)
        x (* 150 (q/cos angle))
        y (* 150 (q/sin angle))]
    ; Move origin point to the center of the sketch.
    (q/with-translation [(/ (q/width) 2)
                         (/ (q/height) 2)]
      ; Draw the circle.
      (q/ellipse x y 100 100))))

(q/defsketch my-stuff
  :title "You spin my circle right round"
  :size [500 500]
  ; setup function called only once, during sketch initialization.
  :setup setup
  ; update-state is called on each iteration before draw-state.
  :update update-state
  :draw draw-state
  :features [:keep-on-top]
  ; This sketch uses functional-mode middleware.
  ; Check quil wiki for more info about middlewares and particularly
  ; fun-mode.
  :middleware [m/fun-mode])
avillega commented 3 years ago

If you want to use lein run to execute your sketch you need a -main function. other options to execute it would be using the repl. Something like this.