Peter,

We asked us the same question some weeks ago, on clojuredev.

We took the path to follow how eclipse launches a java application
when the user requires it to test it.
So we created a customized "launch configuration" (sorry, eclipse
jargon), that is just a classical eclipse java launcher with some
options predefined.

To enable the user work against the clojure version he wants, we
require him to have clojure library as a standard library dependency
on the classpath of his eclipse project.

I think you could do quite the same thing for IntelliJ.

We did that because of several reasons :

- we wanted the user to be able use his own version of clojure, not an
imposed one
- we wanted the user to be able to have several clojures running at
the same time
- we absolutely wanted to prevent the user run his code in the eclipse
VM !
- we wanted regular eclipse users to feel at home with clojuredev,
having in mind that having a smooth migration path from java to
clojure, first by just incorporating bits of clojure in a (n already
existing) java project codebase, could be a good thing.

So we took the road you described by quoting Stuart. We call a "bridge
function" that takes strings and returns strings (or core clojure
datastructures : maps, vectors, strings, keys, java.lang basic types).

This bridge function runs on the eclipse JVM, and calls a server we
systematically install in the remote JVM when the user launches his
project.

The code for the client part is here :
http://code.google.com/p/clojure-dev/source/browse/clojuredev/trunk/src/clojuredev/debug/clientrepl.clj
The code for the server part is here :
http://code.google.com/p/clojure-dev/source/browse/clojuredev/trunk/src/clojuredev/debug/serverrepl.clj
(and yes, it's yet another variation on the repl over socket)

HTH,

--
Laurent

On 22 jan, 22:43, Peter Wolf <opus...@gmail.com> wrote:
> This is a rejuvenation of the old "calling Java from Clojure" thread
>
> I have been looking at the solutions from Mark
> /
>    1) From a Java application, read a text file containing Clojure code
>    and invoke specific functions it defines from Java code.
>    2) Compile Clojure code to bytecode and use it from a Java application
>    just like any other Java code.
>
>    An example of the first option is provided at
>
> http://markmail.org/message/tx23zaxf77b6widh#query:%22calling%20Cloju....
>
>   /  
>
> and Stuart
> /
>    Here's how I do it:
>
>    import clojure.lang.RT;
>    import clojure.lang.Var;
>    ...
>    RT.loadResourceScript("source/file/on/classpath/here.clj");
>    Var myfunction = RT.var("my-namespace", "my-function");
>    myfunction.invoke("arg 1", "arg 2", ...); /
>
> Where is the documentation on this Java API?  In particular, all these
> functions seem to side-effect a single Clojure image.
>
> Can I create several disjoint images?  Can I stop or destroy an image
> that has run amok?
>
> I want to use this for the IntelliJ plugin, and I don't want bogus user
> code to clobber the IDE.  I also want the defined symbols for a file to
> be a function just of the code in that file, not all the files that
> happen to be loaded by the IDE at the moment.  How does Swank handle this?
>
> Thanks
> Peter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to