【问题标题】:Using SWT with "lein repl" on Mac OS X在 Mac OS X 上使用带有“lein repl”的 SWT
【发布时间】:2012-12-26 22:20:14
【问题描述】:

我无法让 nREPL 在 Mac OS X 上使用 SWT。

要重现该问题,请使用以下 project.clj 文件创建一个新的 SWT 项目:

(defproject swttest "0.1.0"
  :description "Foo"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.eclipse.swt/org.eclipse.swt.cocoa.macosx.x86_64 "3.8"]]
  :jvm-opts ["-XstartOnFirstThread"]
  :repositories [["swt-repo" "https://swt-repo.googlecode.com/svn/repo/"]])

然后使用“lein repl”启动 REPL。最后,运行以下命令:

user> (org.eclipse.swt.widgets.Display.)

出现以下错误:

SWTException Invalid thread access  org.eclipse.swt.SWT.error (:-1)

我怎样才能让它工作?

【问题讨论】:

    标签: clojure swt read-eval-print-loop leiningen


    【解决方案1】:

    找到了解决办法。不要使用 nREPL,而是在“哑”REPL 中运行它,方法是修改 project.clj 文件以包含“哑铃”别名,如下所示:

    (defproject swttest "0.1.0"
      :description "Foo"
      :dependencies [[org.clojure/clojure "1.4.0"]
                     [org.eclipse.swt/org.eclipse.swt.cocoa.macosx.x86_64 "3.8"]]
      :jvm-opts ["-XstartOnFirstThread"]
      :aliases {"dumbrepl" ["trampoline" "run" "-m" "clojure.main/main"]}
      :repositories [["swt-repo" "https://swt-repo.googlecode.com/svn/repo/"]])
    

    然后运行:

    > lein dumbrepl
    

    【讨论】:

      【解决方案2】:

      lein 命令行启动多个 jvm。只有第一个使用 -XstartOnFirstThread 参数运行。您可以通过运行ps -aux|grep java 并查看 lein repl 的功能来验证这一点。这就是您的“dumbrepl”有效的原因。

      【讨论】:

      • 感谢您的信息。这基本上是我想出来的。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-12
      • 1970-01-01
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多