简体   繁体   English

在 Clojure 中重新加载 Java class

[英]Reload a Java class in Clojure

I would be interested in reloading a Java class in Clojure, for example in the REPL.我有兴趣在 Clojure 中重新加载 Java class,例如在 REPL 中。

If a Java class has previously been loaded and used, and, afterwards, it has been changed and recompiled, can the new updated class be reloaded?如果一个Java class之前已经加载使用过,之后又改了重新编译,是否可以重新加载新更新的class?

I have done some searches (for example, How does clojure class reloading work? ), but I have not found a clear way to do it.我已经进行了一些搜索(例如, clojure class 重新加载如何工作? ),但我还没有找到明确的方法。

Thanks.谢谢。

You can use a modified JVM that you can use with Clojure to accomplish that, DCEVM .您可以使用修改后的 JVM 与 Clojure 一起使用来完成此操作, DCEVM I made a small project to demonstrate how to set it up.我做了一个小项目来演示如何设置它。 DCEVM will automatically reload Java classes in a running JVM process when those classes are updated.当更新这些类时,DCEVM 将在正在运行的 JVM 进程中自动重新加载 Java 类。 The good thing with DCEVM is that you don't have to pay for it. DCEVM 的好处是您不必为此付费。 DCEVM seems to work most of the time, but not always. DCEVM 似乎大部分时间都在工作,但并非总是如此。 Sometimes I have to restart the REPL to get the new clases loaded.有时我必须重新启动 REPL 才能加载新的类。

Before using DCEVM I tried JRebel .在使用 DCEVM 之前,我尝试了 JRebel Just like DCEVM, JRebel will also reload Java classes.就像 DCEVM 一样,JRebel 也会重新加载 Java 类。 In my experience, JRebel worked a lot more reliably than DCEVM, but unfortunately it is quite expensive to buy.根据我的经验,JRebel 的工作比 DCEVM 可靠得多,但不幸的是,它的购买成本相当高。 You can try it out, though, for a limited time period for free.不过,您可以在有限的时间内免费试用。

Update: I found this answer too, which seems quite consistent with what I wrote regarding DCEVM vs JRebel.更新:我也找到了这个答案,这似乎与我写的关于 DCEVM 与 JRebel 的内容非常一致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM