Java

GURVINDER SINGH
GURVINDER SINGH
10,589 Points

Installing Java REPL

I will really appreciate if people at treehouse can make a video lesson on how to install 'javarelp'. It turns out to be really difficult to install it on mac.

Jonathan Hector
Jonathan Hector
5,225 Points

http://macappstore.org/javarepl/

Follow these instructions and javarepl will be installed in no time.

6 Answers

Ernest Grzybowski
Ernest Grzybowski
Treehouse Project Reviewer

If you visit the video where the java-repl tool is first talked about, it has helpful links directly below the video in the "Teachers Notes".

If you go to the java-repl GitHub page it gives you the link to the download and tells you how to run it under "Usage".

I understand that most people aren't familiar with running jar files as programs, so I'll list this out step-by-step.

Step 1: Download java-repl.jar

Step 2: Open a terminal and navigate to where the tool was downloaded to. If you downloaded it to your Downloads directory just type cd Downloads/

Step 3: Run this command in the terminal to start the java-repl java -jar javarepl.jar

Step 4: All done! Use ctrl+c to terminate the utility.

Note: I changed your question from "Android" to "Java" because the java-repl tool is never talked about in the Android courses.

I tried the same thing on windows this is what I'm getting: no main manifest attribute, in javarepl.jar

Waldo Alvarado
Waldo Alvarado
16,322 Points

Ernest Grzybowski, thanks for you help but I'm getting this error when I try what you said:

" λ java -jar javarepl.jar Welcome to JavaREPL version 303 (Java HotSpot(TM) Client VM, Java 1.8.0_60)

ERROR: Java compiler not found. This can occur when JavaREPL was run with JRE instead of JDK or JDK is not configured correctly. "

I don't know what that means.

Jonathan Hector
Jonathan Hector
5,225 Points

http://macappstore.org/javarepl/

Follow these instructions and javarepl will be installed in no time.

Michael Acosta Pegoraro
Michael Acosta Pegoraro
4,911 Points

It's turns out to be easier than you think! I found an awesome way of installing a lot of tools via the terminal command.

I went here: http://brew.sh/

To install brew just run this on the terminal: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

it will ask for your/admin password.

Then install javarepl: brew install javarepl

To run it, just type: javarepl

Found the info here: https://www.learnhowtoprogram.com/lessons/java-repl

And you are good to go!

It's also helpful for installing other tools like download managers like wget that I use often on Linux. I switch between Mac and Linux so I am most of the time on the terminal. Even tho Treehouse has the workspace option to work on, I prefer to work local on my computer.

Jeff Bass
Jeff Bass
18,640 Points

Super helpful! Thanks!

Plus you get a nice mug of beer poured for you whenever you install something. https://www.dropbox.com/s/cmgewbz4j5c0qb0/beer.tiff?dl=0

Darin Thompson
Darin Thompson
5,283 Points

I am so thankful for this comment. I was racking my brain trying to figure out how to install this repl. I wasted a lot of time, kind of going through documentation and everything, I had it installed correctly but I kept running java-repl and was about to lose my mind as to why is wasn't working. Thankfully I came here not too long after my ordeal and found the command was actually javarepl no dash or space. Thanks a million.

home-brew is my favorite installation method! Thanks for this!

annient
annient
Pro Student 1,708 Points

I installed brew, and when I wanted to install javarepl with command brew install javarepl, terminal showed: -bash: brew: command not found What did I do wrong? Please help me :(

Jozef Bača
Jozef Bača
4,629 Points

Thanks Ernest, i was searching for it for a long time. :) It is also good to create alias in .bashrc or .bash_aliases (this files should be located in your home folder) like this:

Step 1: Write this line into the file .bashrc or .bash_aliases: alias java-repl='java -jar path/to/file/javarepl.jar'

Step 2: To reload .bashrc or .bash_aliases, write this in terminal: source ~/.bashrc or source ~/.bash_aliases

Step 3: All done! From now on you can run it from terminal by typeing: java-repl

Matthias Seeber
Matthias Seeber
14,167 Points

I can't find the .bashrc file, can you help me to install the java -repl, so that I can run it from the terminal?

Waldo Alvarado
Waldo Alvarado
16,322 Points

Here's what I tried that worked for me.

In the Command line, once you're in the directory where you saved the javarepl.jar

(1) find the location (path) of where you installed you're JDK (java). In my case that was: C:\Program Files\Java\jdk1.7.0_79\bin

(2) Add a "\java" to that path so that you end up with: C:\Program Files\Java\jdk1.7.0_79\bin\java

(3) Encase it in quotes: "C:\Program Files\Java\jdk1.7.0_79\bin\java"

(4) Finally in type in: "C:\Program Files\Java\jdk1.7.0_79\bin\java" -jar javarepl.jar then hit enter and if it works you should see this--------->

Welcome to JavaREPL version 303 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79) Type expression to evaluate, :help for more options or press tab to auto-complete. java>

Jozef Bača
Jozef Bača
4,629 Points

Hi Matthias, i was out from treehouse for a while, so sorry for delay. You are able to find .bashrc in your home folder only when you try install javarepl on linux. But some versions of linux use a different bash, so you need to find out which type of bash you have on your linux distro. And also file is hidden so maybe if you setup to view hidden files, you will find .bashrc. Dot at the beginning of file name, means that the file is hidden.