I am on Windows 10.
I succeed to compile and run this jar.
But when I try to connect to Socket REPL from telnet I get this error and telnet wrote Connection closed by foreign host.
ERROR
Exception in thread "Clojure Connection mine 1" java.io.FileNotFoundException: Could not locate 'clojure/core/server__init.class or 'clojure/core/server.clj on classpath.
Could you please explain what is wrong? :(
package com.echo;
import clojure.java.api.Clojure;
import clojure.lang.IFn;
import clojure.lang.RT;
import clojure.lang.Var;
import clojure.lang.Symbol;
public class Echo {
public static void main(String[] args) {
try {
IFn plus = Clojure.var("clojure.core", "+");
System.out.println( plus.invoke(1, 2).getClass().getSimpleName() );
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("clojure.core.server"));
IFn startServer = Clojure.var("clojure.core.server","start-server");
//Object options = Clojure.read("\"{:port 4555 :accept 'clojure.core.server/repl :name :repl2 :server-daemon false}\"");
startServer.invoke(
Clojure.read("{:port 4555 :accept 'clojure.core.server/repl :name mine :server-daemon false}")
);
System.out.println( "Started" );
}
catch(Exception e)
{
System.out.println( e.getMessage() );
}
}
}
I run like this
java -cp ".\target\echo-1.0-SNAPSHOT.jar;C:\lib\ext\clojure-1.8.0.jar" com.echo.Echo
You shouldn't quote a symbol that you're reading from a string: use clojure.core.server/repl
instead of 'clojure.core.server/repl
. Quoting is used to prevent evaluation; but since you are not evaluating, this just results in an extra quote thrown in where it doesn't belong.