Giter Site home page Giter Site logo

java-repl's Introduction

Java REPL

NOT MAINTAINED: Since Java is now released with REPL this project will no longer be maintained.

Travis GitHub Docker Pulls

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

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 Maven Central. Configure repository and then add Java REPL as dependency:

<dependencies>
    <dependency>
        <groupId>com.javarepl</groupId>
        <artifactId>javarepl</artifactId>
        <version>SOME_VERSION</version>
    </dependency>
</dependencies>

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

$ <PATH_TO_JDK>/bin/java -jar javarepl-SOME_VERSION.jar

License

Distributed under the Apache 2.0

java-repl's People

Contributors

albertlatacz avatar csrcordeiro avatar lostdj avatar nequissimus avatar oakes avatar peterjeschke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-repl's Issues

Allow redefinition of methods

Consider the following:

java> public void sayHello() { System.out.println("hi."); }


java> public void sayHello() { System.out.println("I mean hello."); }
ERROR: sayHello() is already defined in Evaluation$z1i8glqu73y2ok5t4rdh
  public void sayHello() { System.out.println("I mean hello."); }

Ideally, I would be able to redefine methods in order to tweak logic when prototyping code. Currently I workaround this by appending a number, for instance in the example above, I'd use sayHello2()

Save multiline history

When history containing expressions with multiple lines is saved to file and loaded, expressions are split per line, e.g

278  for (int i = 0 ; i < 100 ; i++) {
279  System.out.println(i);
280  }

where it should be

299  for (int i = 0 ; i < 100 ; i++) {
       System.out.println(i);
     }

Add generics support (Was: Executing a for loop fails)

java> for(Integer integer : list) { System.out.println(integer) ; }
ERROR: error: illegal start of expression
for(Integer integer : list) { System.out.println(integer) ; };
^
ERROR: error: ')' expected
for(Integer integer : list) { System.out.println(integer) ; };
^
ERROR: error: not a statement
for(Integer integer : list) { System.out.println(integer) ; };
^
ERROR: error: ';' expected
for(Integer integer : list) { System.out.println(integer) ; };
^
ERROR: error: not a statement
for(Integer integer : list) { System.out.println(integer) ; };
^
ERROR: error: ';' expected
for(Integer integer : list) { System.out.println(integer) ; };

I get the same error if I use a the old for loop syntax

for (int i = 0; i < list.length; i++)

perhaps the for loop is not yet supported?

Curly brace on same line produces error

When I use curly brace at the end of line, error occurs:

java> void test() {
    | while (true) {
    | }
    | }
ERROR: reached end of file while parsing
}
 ^

When I use curly brace on new line, everything is ok:

java> void test() {
    | while (true)
    | {
    | }
    | }
Created method void test()
java>

Support for Array Initializers with primitive types

Currently, using syntax such as int[] arr = new int[] { 1, 2, 3 } causes a ClassCastException to be thrown from the Utils valueToString method.

Example output:

java> int[] arr = new int[] { 1, 2, 3 }
Exception in thread "main" java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
    at javarepl.Utils$1.call(Utils.java:61)
    at javarepl.Utils$1.call(Utils.java:52)
    at javarepl.internal.totallylazy.Functions.call(Functions.java:76)
    at javarepl.internal.totallylazy.Function1.apply(Function1.java:13)
    at javarepl.Utils.valueToString(Utils.java:48)
    at javarepl.Result.toString(Result.java:37)
    at javarepl.Result.toString(Result.java:42)
    at javarepl.internal.totallylazy.Callables$22.call(Callables.java:243)
    at javarepl.internal.totallylazy.Callables$22.call(Callables.java:241)
    at javarepl.internal.totallylazy.Functions.call(Functions.java:76)
    at javarepl.internal.totallylazy.Callers.call(Callers.java:109)
    at javarepl.internal.totallylazy.Some.map(Some.java:60)
    at javarepl.console.commands.EvaluateExpression.evaluate(EvaluateExpression.java:27)
    at javarepl.console.commands.EvaluateExpression.execute(EvaluateExpression.java:20)
    at javarepl.console.commands.Command.execute(Command.java:36)
    at javarepl.console.SimpleConsole$2.call(SimpleConsole.java:73)
    at javarepl.console.SimpleConsole$2.call(SimpleConsole.java:70)
    at javarepl.internal.totallylazy.Rule.call(Rule.java:24)
    at javarepl.internal.totallylazy.Rules.call(Rules.java:53)
    at javarepl.internal.totallylazy.Functions.call(Functions.java:76)
    at javarepl.internal.totallylazy.Function1.apply(Function1.java:13)
    at javarepl.console.SimpleConsole.execute(SimpleConsole.java:25)
    at javarepl.console.rest.RestConsole.execute(RestConsole.java:29)
    at javarepl.Main.main(Main.java:68)

Of note - array initializers work with Objects (the cast above succeeds), it is only for primitive types that this fails.

NPE crash on Intellij IDEA 13

On a fresh install of the newly released IntelliJ IDEA 13 this plugin fails with the following stacktrace when attempting to start the Java REPL either through the menu or by pressing Alt+Shift+J:

java.lang.NullPointerException
    at com.intellij.openapi.actionSystem.EmptyAction.setupAction(EmptyAction.java:59)
    at javarepl.plugin.JavaREPLConsoleHistoryController.configureActions(JavaREPLConsoleHistoryController.java:144)
    at javarepl.plugin.JavaREPLConsoleHistoryController.install(JavaREPLConsoleHistoryController.java:131)
    at javarepl.plugin.JavaREPLConsoleRunner.createConsoleExecActions(JavaREPLConsoleRunner.java:226)
    at javarepl.plugin.JavaREPLConsoleRunner.fillToolBarActions(JavaREPLConsoleRunner.java:189)
    at javarepl.plugin.JavaREPLConsoleRunner.initAndRun(JavaREPLConsoleRunner.java:140)
    at javarepl.plugin.JavaREPLConsoleRunner.run(JavaREPLConsoleRunner.java:84)
    at javarepl.plugin.RunJavaREPLConsoleAction.actionPerformed(RunJavaREPLConsoleAction.java:49)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:162)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:261)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:916)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:231)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:104)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:512)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:44)
    at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:532)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:696)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Allow single statements to end with a semi-colon

This is kind of a stylistic choice, and I understand if you want the behavior to remain as-is.
I'm not a fan of the following:

java> int currentIndex = -1;
ERROR: unreachable statement
    -1;;

Especially considering that a multi-line entry, such as a method definition, requires that the statements be terminated with a semi-colon:

java> void foo() {
    | int x = 0;
    | }

It feels inconsistent to me that I should not include it for single statements, but I should include it for anything more complex.

What's your take on this?

Extra characters in prompt

Hi there,
I am running javarepl.jar through cmd and I am having extra characters in the beggining:

←[0m←[0m
←[0m←[1mjava> ←[0mSystem.out.println("Hello World");
←[32mlol
←[0m←[32m
←[0m←[0m
←[0m←[1mjava> ←[0m

NullPointerException when opening REPL in Cardea

java.lang.NullPointerException
    at com.intellij.openapi.actionSystem.EmptyAction.setupAction(EmptyAction.java:59)
    at javarepl.plugin.JavaREPLConsoleHistoryController.configureActions(JavaREPLConsoleHistoryController.java:144)
    at javarepl.plugin.JavaREPLConsoleHistoryController.install(JavaREPLConsoleHistoryController.java:131)
    at javarepl.plugin.JavaREPLConsoleRunner.createConsoleExecActions(JavaREPLConsoleRunner.java:226)
    at javarepl.plugin.JavaREPLConsoleRunner.fillToolBarActions(JavaREPLConsoleRunner.java:189)
    at javarepl.plugin.JavaREPLConsoleRunner.initAndRun(JavaREPLConsoleRunner.java:140)
    at javarepl.plugin.JavaREPLConsoleRunner.run(JavaREPLConsoleRunner.java:84)
    at javarepl.plugin.RunJavaREPLConsoleAction.actionPerformed(RunJavaREPLConsoleAction.java:49)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:162)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:260)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:892)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:114)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:230)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:104)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:512)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:44)
    at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:532)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:682)
    at java.awt.EventQueue$3.run(EventQueue.java:680)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:696)
    at java.awt.EventQueue$4.run(EventQueue.java:694)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
    at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:696)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

IDEA (Cardea) IU 132.425

Anonymous classes don't work

Here is an example:

java> class Foo {};
Created type Foo
java> a = new Foo() { public int bar(){ return 1; } };
Foo a = Evaluation$8xps690yev1jfqzdto5r$1@615c027c
java> a.bar()
ERROR: error: cannot find symbol
a.bar();
^
java> a
Foo a = Evaluation$8xps690yev1jfqzdto5r$1@615c027c

HashMap doesn't seem to work

java> String x="aa"
String x = "aa"

java> x
String res1 = "aa"

java> HashMap< String, String > h = new HashMap< String, String >()

java> h
ERROR: error: cannot find symbol
h;
^

java>

Instance variables are declared final

When an expression such as int counter = 0 is entered, the generated source declares the counter identifier as being final. This means that when attempting to follow that expression with something like counter++, the following error is generated:

java> counter++
ERROR: cannot assign a value to final variable counter
    counter++;
    ^

I know you are using a lot of things from the totallylazy functional library, which likely requires that many of the parameters provided be final in order to use them with anonymous inner classes. If possible, it would be really great to have mutable identifiers here :-)

Persist History Across Sessions

If history was persisted across sessions, one could easily jump back into the repl and make minor tweaks to the last thing they tried, or keep common imports in the history buffer as a way of re-importing them each time the repl is started. Given that the history is already stored, this may be as simple as dumping it to a ~/.jrepl_history file before the application terminates.

JDK8 Support (importing standard library?)

java>  public static Function<Integer, Function<Integer, Integer>> add() {
        return x -> y -> x + y;
    }
ERROR: error: cannot find symbol
  public static Function<Integer, Function<Integer, Integer>> add();
                ^
ERROR: error: cannot find symbol
  public static Function<Integer, Function<Integer, Integer>> add();
                                  ^
ERROR: error: missing method body, or declare abstract
  public static Function<Integer, Function<Integer, Integer>> add();
                                                              ^
java>  

import does not work

Welcome to JavaREPL version 261 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65)
Type expression to evaluate, :help for more options or press tab to auto-complete.
java> import Math;
ERROR: /var/folders/tb/_vd84ly54rl1n5r16nytjx6h0000gn/T/JavaREPL/b5d11d72-3df0-4bd8-96e9-245277764417/Evaluation.java:5: '.' expected
import Math;;
^

Add the current project class path to the default class path

When I start a new JavaREPL pane in IntelliJ, all the auto-completion for the classes in the project works nicely, but it seems like JavaREPL fails to resolve those classes on evaluation. For example:

java> import io.netty.util.*
ERROR: error: package io.netty.util does not exist

import io.netty.util.*;
^

Not sure if primitive types aren't meant to be supported...

java> int x = 2;
int x = 2
java> x++;
ERROR: /var/folders/tb/_vd84ly54rl1n5r16nytjx6h0000gn/T/JavaREPL/63a876b6-26b5-47be-b887-81a9df0d2b2f/Evaluation.java:7: type parameters of T cannot be determined; no unique maximal instance exists for type variable T with upper bounds int,java.lang.Object
public int x = valueOf("x");

IntelliJ plugin: execute statements on ENTER

Unlike the standalone version, the IntelliJ plugin does not execute statements when pressing ENTER. It requires pressing Shift+ENTER instead.

Could the plugin be changed to execute statements on ENTER, like the standalone console version?

The vast majority of statements I enter when using the plugin are single line, and I keep pressing ENTER and sitting there staring at the console until I realize the statement is not executing and I should press Shift+ENTER instead. :)

Perhaps the behavior could be reversed: ENTER executes the statement, while Shift+ENTER allows to create a multi-line statement.

Thanks for this awesome plugin, it has improved my programming experience tremendously. Previously I used the Scrappy plugin to accomplish something similar, but your REPL is far more comfortable and superior.

The console at www.javarepl.com stopps working after some idle time

When I go to www.javarepl.com and enter something like
java> "hello"

There is a three second pause, and then it comes back with
String res0 = "hello"

Now the second thing aI type comes back in less than once second:
java> "world"
String res1 = "world"

So far so good. Now if I don't type for a period of time (ten minutes or so, maybe an hour) and then type something again

java> "Hello again"

It no longer evaluates it and just returns emptiness

If I refresh the page in the browser, it starts working again.

Maybe this dead state can be detected, and the server can restart the repl? Or the ui could say that the user need to refresh the page.

Can't run any code on Windows

java -version

java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

java -jar javarepl.jar

Welcome to JavaREPL version 61 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17)
Type in expression to evaluate.
Type :help for more options.

import java.io.*
java.lang.NullPointerException
at javarepl.Evaluator.compile(Evaluator.java:204)
at javarepl.Evaluator.evaluateExpression(Evaluator.java:170)
at javarepl.Evaluator.evaluate(Evaluator.java:132)
at javarepl.Evaluator.evaluate(Evaluator.java:46)
at javarepl.commands.EvaluateExpression.evaluate(EvaluateExpression.java:26)
at javarepl.commands.EvaluateExpression.call(EvaluateExpression.java:21)
at javarepl.commands.EvaluateExpression.call(EvaluateExpression.java:15)
at javarepl.internal.totallylazy.$Functions$7.call(Functions.java:118)
at javarepl.internal.totallylazy.$Rule.call(Rule.java:24)
at javarepl.internal.totallylazy.$Rules.call(Rules.java:53)
at javarepl.internal.totallylazy.$Functions.call(Functions.java:76)
at javarepl.internal.totallylazy.$Function1.apply(Function1.java:13)
at javarepl.Main.run(Main.java:79)
at javarepl.Main.main(Main.java:25)

Display method signatures for match candidates

Enhancement, related to #22 - The new code completion support is awesome. What do you think about displaying method matches with signatures?

For instance:

java> public void someStringMethod() { }
Created method void someStringMethod()

java> someString   // <-- tab
someString          someStringTwo       someStringMethod(   
java> public void someStringMethod(int x) { }
Created method void someStringMethod(int)

java> someString // <-- tab
someString          someStringTwo       someStringMethod(   

Would instead display (something like):

java> public void someStringMethod() { }
Created method void someStringMethod()

java> someString  // <-- tab
someString          someStringTwo       someStringMethod()   
java> public void someStringMethod(int x) { }
Created method void someStringMethod(int)

java> someString  // <-- tab
someString          someStringTwo       someStringMethod()     someStringMethod(int)   

Again, this is an enhancement request only :-)

Statements containing '!' break the ConsoleReader

Reproduce with:

java> boolean realityIsBroken = (1 != 1)
Exception in thread "main" java.lang.IllegalArgumentException: != 1): event not found
    at javarepl.internal.jline.console.ConsoleReader.expandEvents(ConsoleReader.java:702)
    at javarepl.internal.jline.console.ConsoleReader.finishBuffer(ConsoleReader.java:577)
    at javarepl.internal.jline.console.ConsoleReader.accept(ConsoleReader.java:1883)
    at javarepl.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2455)
    at javarepl.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2126)
    at javarepl.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2114)
    at javarepl.Main$2.call(Main.java:177)
    at javarepl.Main$2.call(Main.java:157)
    at javarepl.internal.totallylazy.Functions.call(Functions.java:76)
    at javarepl.internal.totallylazy.Function1.apply(Function1.java:13)
    at javarepl.ExpressionReader.readExpression(ExpressionReader.java:28)
    at javarepl.Main.main(Main.java:71)

Unfortunately, this is a problem with the jline library. I have filed an issue with them here, though I'm not sure the project is still being maintained.

$CLASSPATH not recognized

I have my CLASSPATH environment variable set to include two directories on my hard drive where there are files I want to use. But when I start java-repl.jar, those classes are not available.

Is there some way to tell java-repl where to find my classes?

Note I am not using an IDE. Just the command line tools javac and java.


Here is the output of my CLASSPATH:

echo $CLASSPATH
.:/home/vagrant/j/class_files/algs4_files/:/home/vagrant/j/class_files/stdlib/

First word in one liner getting chopped

While parsing several statements entered on one line java-repl appears to chop the first word.
Example:

java> Boolean a = null; boolean b = false; boolean isSetA = a != null; if((!isSetA || a) && b){ System.out.println("a is "+a+", b is "+b+", isSetA is"+isSetA);}

ERROR: error: cannot find symbol
    null; boolean b = false; boolean isSetA = a != null; if((!isSetA || a) && b){ System.out.println("a is "+a+", b is "+b+", isSetA is"+isSetA);};
                                              ^
ERROR: error: cannot find symbol
    null; boolean b = false; boolean isSetA = a != null; if((!isSetA || a) && b){ System.out.println("a is "+a+", b is "+b+", isSetA is"+isSetA);};
                                                                        ^
ERROR: error: cannot find symbol
    null; boolean b = false; boolean isSetA = a != null; if((!isSetA || a) && b){ System.out.println("a is "+a+", b is "+b+", isSetA is"+isSetA);};
                                                                                                             ^

Extended example:
https://gist.github.com/dannypurcell/ec08e90fc989ac34da66/raw/f09e18ef3ca6f832531c69f6100fdfb492ee9227/jrepl+test

Builds fine under Ubuntu but not Cygwin

package:
    [unzip] Expanding: C:\work\experiments\java\java-repl\build\artifacts\javarepl-dev.build-tests.jar into C:\work\experiments\java\java-repl\build\artifacts\reports.unzipped.jar
      [zip] Building zip: C:\work\experiments\java\java-repl\build\artifacts\javarepl-dev.build-sources.jar
      [zip] Building zip: C:\work\experiments\java\java-repl\build\artifacts\javarepl-dev.build-test-sources.jar
    [junit] TEST javarepl.EvaluatorTest FAILED
    [junit] Tests FAILED
   [delete] Deleting directory C:\work\experiments\java\java-repl\build\artifacts\reports.unzipped.jar

BUILD FAILED
C:\work\experiments\java\java-repl\build.xml:185: The following error occurred while executing this line:
C:\work\experiments\java\java-repl\build.xml:106: The following error occurred while executing this line:
C:\work\experiments\java\java-repl\build\macros.xml:110: Tests failed

Build failed (Did I miss dependencies other than ant and JDK 6+?)

ant is returning nonzero with the following ant, JDK and JVM:

Apache Ant(TM) version 1.8.2 compiled on December 3 2011

javac 1.6.0_30 (Openjdk-6-jdk in Ubuntu 12.04 precise pangolin repos as of posting)

java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-1ubuntu2~0.12.04.1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

It has failed with the following:
[junit] TEST javarepl.console.SimpleConsoleTest FAILED
[junit] Tests FAILED
[delete] Deleting directory /home/dmorris/java-repl/build/artifacts/reports.unzipped.jar

BUILD FAILED
/home/dmorris/java-repl/build.xml:185: The following error occurred while executing this line:
/home/dmorris/java-repl/build.xml:106: The following error occurred while executing this line:
/home/dmorris/java-repl/build/macros.xml:112: Tests failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.