使用 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

相关文章
|
12月前
|
安全 Java Shell
JDK9特性——模块化&REPL工具
谈到Java9大家往往第一个想到的就是Jigsaw项目(后改名为Modularity)。众所周知,Java已经发展超过20年(95年最初发布),Java和相关生态在不断丰富的同时也越来越暴露出一些问题:
130 0
在 Java 9 的JShell中 跟Kotlin 的REPL中尽情体验函数式编程乐趣吧
Java 9 JShell : 螢幕快照 2017-09-25 22.58.02.png jshell> List alphabet = List.
1194 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, .
1264 0
|
JavaScript 前端开发 Java
|
10天前
|
存储 缓存 安全
【Java面试题汇总】多线程、JUC、锁篇(2023版)
线程和进程的区别、CAS的ABA问题、AQS、哪些地方使用了CAS、怎么保证线程安全、线程同步方式、synchronized的用法及原理、Lock、volatile、线程的六个状态、ThreadLocal、线程通信方式、创建方式、两种创建线程池的方法、线程池设置合适的线程数、线程安全的集合?ConcurrentHashMap、JUC
【Java面试题汇总】多线程、JUC、锁篇(2023版)
|
4天前
|
缓存 Java 应用服务中间件
Java虚拟线程探究与性能解析
本文主要介绍了阿里云在Java-虚拟-线程任务中的新进展和技术细节。
|
2天前
|
Java 开发者
Java中的多线程基础与应用
【9月更文挑战第22天】在Java的世界中,多线程是一块基石,它支撑着现代并发编程的大厦。本文将深入浅出地介绍Java中多线程的基本概念、创建方法以及常见的应用场景,帮助读者理解并掌握这一核心技术。
|
4天前
|
Java
领略Lock接口的风采,通过实战演练,让你迅速掌握这门高深武艺,成为Java多线程领域的武林盟主
领略Lock接口的风采,通过实战演练,让你迅速掌握这门高深武艺,成为Java多线程领域的武林盟主
20 7
|
3天前
|
Java 程序员
Java中的多线程基础与实践
【9月更文挑战第21天】本文旨在引导读者深入理解Java多线程的核心概念,通过生动的比喻和实例,揭示线程创建、同步机制以及常见并发工具类的使用。文章将带领读者从理论到实践,逐步掌握如何在Java中高效地运用多线程技术。