使用 Java REPL

简介: chapter1_basics$ java -jar javarepl-428.jarWelcome to JavaREPL version 428 (Java HotSpot(TM) 64-Bit Server VM, Java 1.

chapter1_basics$ java -jar javarepl-428.jar

Welcome to JavaREPL version 428 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40)

Type expression to evaluate, :help for more options or press tab to auto-complete.

Connected to local instance at http://localhost:49659

java> System.out.println("Hello,World")

Hello,World

java> System.out.println("Hello,World"+new Date())

Hello,WorldTue Aug 01 10:08:21 CST 2017

java> System.out.println("Hello,World! "+new Date())

Hello,World! Tue Aug 01 10:08:29 CST 2017

java> 1+1

java.lang.Integer res0 = 2

java>


下载地址:

https://github.com/albertlatacz/java-repl/releases

Java REPL

Java REPL is a simple Read-Eval-Print-Loop for Java language.

  • Support for most of Java language constructs

  • Access from console as well as web terminal via browser

  • Create imports, methods, classes, enums and interfaces

  • Load classes from any jar file or directory (including web urls)

  • Load and evaluate expression from file

  • List previous results, imports, created types and methods

  • Show history of evaluations

  • Search and evaluate expression from history

  • Clear and replay previous evaluations

  • Load and evaluate any Java source file

  • Basic code completion for results, classes and methods

  • Coloured output for console and web terminal

Web version is available at www.javarepl.com.

Build

Building Java REPL requires the gradle.

After cloning the git repository, navigate over to it and run:


$ gradle shadowJar

After this completes, the jar completed with bundled dependencies will be located at build/libs/javarepl-dev.jar

Type the following to run


$ java -jar build/libs/javarepl-dev.jar

Releases

Releases are automatically released to

. Configure repository and then add Java REPL as dependency:




com.javarepl

javarepl

SOME_VERSION

Usage

To run Java REPL you need to install Java Development Kit (JDK). Download it from here and follow install instructions. Once JDK is installed and configured, download latest Java REPL release from GitHub or Bintray then run:


$ java -jar javarepl-SOME_VERSION.jar

If this doesn't work try to run pointing directly to java executable within JDK, like so


$ /bin/java -jar javarepl-SOME_VERSION.jar

License

Distributed under the Apache 2.0

相关文章
|
安全 Java Shell
JDK9特性——模块化&REPL工具
谈到Java9大家往往第一个想到的就是Jigsaw项目(后改名为Modularity)。众所周知,Java已经发展超过20年(95年最初发布),Java和相关生态在不断丰富的同时也越来越暴露出一些问题:
291 0
|
XML 安全 Java
使用Kotlin 1.1.5 的REPL 来简单分析一下Java 9 中的$ jmod list java.base.jmod
$ jmod list java.base.jmod 命令行列出了 模块 java.base.jmod 中所有文件(.class文件, .dat, .jar, .
1435 0
在 Java 9 的JShell中 跟Kotlin 的REPL中尽情体验函数式编程乐趣吧
Java 9 JShell : 螢幕快照 2017-09-25 22.58.02.png jshell> List alphabet = List.
1331 0
|
JavaScript 前端开发 Java
|
5月前
|
JSON 网络协议 安全
【Java】(10)进程与线程的关系、Tread类;讲解基本线程安全、网络编程内容;JSON序列化与反序列化
几乎所有的操作系统都支持进程的概念,进程是处于运行过程中的程序,并且具有一定的独立功能,进程是系统进行资源分配和调度的一个独立单位一般而言,进程包含如下三个特征。独立性动态性并发性。
286 1
|
5月前
|
JSON 网络协议 安全
【Java基础】(1)进程与线程的关系、Tread类;讲解基本线程安全、网络编程内容;JSON序列化与反序列化
几乎所有的操作系统都支持进程的概念,进程是处于运行过程中的程序,并且具有一定的独立功能,进程是系统进行资源分配和调度的一个独立单位一般而言,进程包含如下三个特征。独立性动态性并发性。
308 1
|
6月前
|
数据采集 存储 弹性计算
高并发Java爬虫的瓶颈分析与动态线程优化方案
高并发Java爬虫的瓶颈分析与动态线程优化方案
Java 数据库 Spring
272 0
|
6月前
|
算法 Java
Java多线程编程:实现线程间数据共享机制
以上就是Java中几种主要处理多线程序列化资源以及协调各自独立运行但需相互配合以完成任务threads 的技术手段与策略。正确应用上述技术将大大增强你程序稳定性与效率同时也降低bug出现率因此深刻理解每项技术背后理论至关重要.
456 16