1

我在 Windows 10 上。我成功编译并运行了这个 jar。但是当我尝试从 telnet 连接到 Socket REPL 时,我收到了这个错误,并且 telnet 写道Connection closed by foreign host.

错误

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.

你能解释一下有什么问题吗?:(

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() );
        }
    }

}

我这样跑 java -cp ".\target\echo-1.0-SNAPSHOT.jar;C:\lib\ext\clojure-1.8.0.jar" com.echo.Echo

4

1 回答 1

2

您不应该引用从字符串中读取的符号:使用clojure.core.server/repl而不是'clojure.core.server/repl. 引用用于防止评估;但由于您没有进行评估,这只会导致在它不属于的地方抛出一个额外的引号。

于 2019-01-17T17:31:25.890 回答