By Chiccodb00 https://www.youtube.com/channel/UCtF8xxYtL6cVSVP2wkMj1Sg
Hi, I'm Chiccodb00
in this video I'll explain the basic usage
and JShell functions.
JShell, is one of the novelties introduced with Java 9
which I have already discussed in the video
available at the top right.
In order to run it on Linux,
just install Java 9 and run the "jshell" command
for Windows, you must always have Java 9 installed
but trying to typing jshell on the terminal we would get
an error message that warns us that the jshell command
isn't recognized, in fact you have to add the JDK9
installation folder to the system path
to do this, simultaneously press the Windows key and "R"
and type "control panel" followed by enter
from here we go to "System and Security"
"System", "Advanced System Settings"
"Environment variables".
At this point we go under "System Variables"
select "Path" and "Edit ..."
at this point you can see two different windows
based on the Windows version, I will do the procedure
both at the same time.
If you are presented with a screen similar to the one on the left
click on "New" and write "C:\Program Files\Java\jdk-9\bin"
finally click on "OK".
If you are presented with a screen similar to the one on the right
go to the end of the "Variable Value" text box
and add ";C:\Program Files\Java\jdk-9\bin;",
finally click on "OK"
on the screen containing all the environment variables
click again on "OK" and close all other windows.
Now we're ready to use JShell
to do that, simultaneously press the Windows and R key
write "jshell" and press enter.
After a few moments there will be a welcome message,
then follow the instructions by typing "/help intro"
in the message that appears you'll be told that JShell
is a tool that allows us to run code in Java
and get instant results
that we can declare methods, variables etc ...
and we can also perform expressions like x + x.
I would begin by declaring an integer called t with value 5
then I write "int t = 5" (here doesn't even need the semicolons)
and pressing enter will show "t ==> 5",
Now we can perform some operations on this variable
such as printing numbers from 1 to t using a for loop
then write "for (int i = 0; i <t; i ++)"
this time hitting enter will not return any output
as it is waiting for the instructions to be executed within the for
then write "System.out.println(i+1)"
pressing enter will run the cycle,
because as a result will give us 1, 2, 3, 4, 5.
You can notice how JShell can be used
also as a calculator, for example, writing "4*4"
and hitting enter will return us 16.
Now let's go to JShell's actual commands
let's start by /list that allows us to print
the "historical" of all the commands we have performed,
in our case it will return:
1: int t = 5;
2: for(int i = 0; i<t; i++) System.out.println(i+1);
3: 4*4
The /list command can also be used to get other informations
for example writing /list and the id of an instruction,
it will return the instruction
if we write /list -start, we will see all the imported classes,
while if we write /list -all we will get both the imported classes
both the instructions executed.
We can also save our hard work
using the /save command followed by the name of the file
then reopen it by writing /open and the filename
note that the /open command will also execute the entire snippet.
Before you save the file you may want to remove an instruction
that you do not want it to appear,
to do that we write /drop and the id of an instruction,
it is obtained when the instruction /list is executed,
since it is the number before ":"
for example we could remove the 3rd statement with /drop 3,
if we want to change an instruction
just write /edit and the instruction id
for example we can make sure that instead
printing the numbers starting from 1,
print them from 0, to do that we write /edit 2,
at this point it will open a window called "JShell Edit Pad"
which contains the current instruction,
and in our case also the condition,
then within the same we modify i + 1
with i, click on "Accept" and "Exit".
It should be noted that in case of a statement
it will be "moved" at the bottom of the history,
and in the case of a for, a copy will be created at the end.
We can see the declared variables and their values
through the /vars command and the methods with their signatures with /methods.
You can re-run a specified snippet
inside an id writing / and the id
Finally, you can reset the Jshell
via the /reset command.
I have omitted some commands,
which are available by writing /help.
If the video helped you understand the subject,
leave a like,
otherwise leave a dislike.
Anyway, you can always comment to help me improve my future videos!
For more infomation >> il Calcio ad Ascia come non lo hai mai visto prima - Difesa Personale - Duration: 4:39.
For more infomation >> Cyriax Manipulação Lombar 3: Leg Over c/ Flexão Lateral p/ Lombalgia - Fisioterapia Dr. Robson Sitta - Duration: 4:16.
For more infomation >> Melhores Lencinhos Umedecidos do Mundo | Cegonha Importadora - Duration: 9:04.
For more infomation >> Un Global Ambassador d'eccezione - Duration: 0:57.
For more infomation >> CÉU OU INFERNO. QUAL A SUA ESCOLHA? - #28 Momento com Deus - Duration: 3:40. 


For more infomation >> Roger Waters aggiunge una data italiana al tour: 3 giorni a Bologna.HD - Duration: 5:12.
For more infomation >> Roy Paci canta il bello del mondo come fosse una favola: Valelapena! L'intervista.HD - Duration: 6:45.
For more infomation >> Grande Fratello Vip, sospetti sulla squalifica di Marco Predolin: è tutto finto? | M.C.G.S - Duration: 3:40.
For more infomation >> Kika Martinez conta como manter a forma na gravidez - starFIT28 - Duration: 3:27.
For more infomation >> Tiziano Ferro: esce l'edizione speciale di "Il mestiere della vita".HD - Duration: 4:54.
For more infomation >> Cả làng đã phát hiện ra chuyện bên cái di ảnh và Vợ mới Cưới là thế này đây ... - Duration: 35:12.
For more infomation >> [Soluzione 100%] Tomb Raider 1 - Liv. 3: Lost Valley - Con spiegazioni e commenti - Duration: 18:30.
For more infomation >> 三菱・RVRが予防安全の「e-Assist」を追加する一部改良を実施。デザインもよりスポーティーに-車の最新ニュース - Duration: 3:01.
For more infomation >> 岡田将生が木村文乃、佐々木希らを狂わせる 『伊藤くん A to E』新映像 - Duration: 2:26.
For more infomation >> Catch the mother of all news t...
For more infomation >> Nissan Pulsar 1.2 DIG-T N-CONNECTA *DEMOVOORDEEL + achteruitrijcamera* - Duration: 0:57. 







For more infomation >> 이영애 이란성 쌍둥이 자녀 - Duration: 4:26. 




For more infomation >> Tổng hợp những mẫu ốp lưng Samsung Galaxy Note 8 đẹp nhất - Duration: 5:47.
For more infomation >> 前進芝加哥Ebony Fashion Fair血拼古董服|珍藏時尚迷#15|VOGUE - Duration: 2:25.
For more infomation >> Drap giường màu xanh I Chăn ra Hàn Quốc cao cấp họa tiết kẹo dễ thương KT2V-008 - Duration: 0:23. 
No comments:
Post a Comment