Clojure/Java 连接到 REPL 时出错 - java.io.FileNotFoundException: 找不到 'clojure/core/server__init.class
Clojure/Java error when connecting to REPL - java.io.FileNotFoundException: Could not locate 'clojure/core/server__init.class
我在 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
您不应引用从字符串中读取的符号:使用 clojure.core.server/repl
而不是 'clojure.core.server/repl
。引用用于防止求值;但由于您没有评估,这只会导致在不属于它的地方抛出一个额外的引号。
我在 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
您不应引用从字符串中读取的符号:使用 clojure.core.server/repl
而不是 'clojure.core.server/repl
。引用用于防止求值;但由于您没有评估,这只会导致在不属于它的地方抛出一个额外的引号。