From the course: Java Microservices with GraalVM
Installing GraalVM
From the course: Java Microservices with GraalVM
Installing GraalVM
- [Instructor] Now, before we get into using the GraalVM, 2 we need to install it on your machine. 3 I'm going to start here with just some general instructions 4 about how to install the GraalVM, 5 and then we'll go into more specifics. 6 Essentially, you're going to download the archive, 7 you'll unpack it, you'll put that location that you 8 unpack it in on your path, and on a Mac, 9 it's a little bit different, but we'll walk through that. 10 You'll install the native image tooling, 11 and all of this can really be found 12 at this getting started section. 13 So let's jump over there 14 and take a look at the real details. 15 On the getting started page, if you scroll down 16 a little bit, you'll see instructions to install GraalVM. 17 there's Linux, macOS 10, and Windows instructions. 18 I'm on a Mac, so I'm going to follow those instructions. 19 You need to do the same based on your operating system. 20 But what you see here is that, on a Mac, 21 Java goes into a certain location, 22 and there's all kinds of details about how to do that. 23 But the first thing that you need to do is you need to go to 24 the GitHub repository and download that artifact. 25 So we'll go ahead and jump there. 26 And this is the community edition, 20.1.0, 27 that I'm downloading. 28 So I'm going to look for Darwin AMD 64. 29 That's what I'm running on my machine. 30 And I'm going to click that link to download it. 31 And we'll let that download run. 32 So now that we've got that file downloaded, 33 let's jump over here into our terminal, and I'm going to go 34 to my downloads directory, and you'll see that I have 35 that tarball that has been downloaded. 36 Now, if you're on a Mac, sometimes this will unzip itself 37 when you do a download, depending on your settings. 38 If that happens, just go to your recycle bin, 39 move that over into your downloads folder, 40 and you should be good to go. 41 So from here, the first command I'm going to execute 42 is I'm going to unpack this thing. 43 So I'm going to do a tar XVF on the artifact itself. 44 And allow it to unpack. 45 So let's do an LL sesh on this command, 46 and I've got an alias for that. 47 So you'll see that we have a tarball 48 and our directory itself. 49 So what we need to do now is, 50 we need to do a sudo move on the directory, 51 and we need to move that 52 to /Library/Java/JavaVirtualMachines. 53 Again, these are instructions for Mac, 54 it's different on other operating systems, 55 but I'm following the instructions from that website. 56 So, because I did a sudo, 57 I need to enter my password. 58 And we will go ahead and now go to that library folder. 59 And you'll see, I've got four JDKs installed on my machine. 60 Now, on a Mac, you can do a user/libexec/java_home -v, 61 and you'll see that we have the same things pointing. 62 The standard JVM is going to get priority in most cases. 63 So that's what is currently the home directory, 64 and I'm running 11.0.7. 65 So we need to go in and modify our path in order 66 to pick up the GraalVM instead of the standard VM. 67 So the first thing that I want to do here before I go in 68 and modify that file is I want to go ahead 69 and go into that directory. 70 And I'm going to go into the contents and home, 71 and there's a reason I do this, and it's because I tend to 72 type poorly when I'm typing out long commands, 73 so this way I can copy that entire directory into my buffer. 74 And now I can do a VI on my Z shell RC file. 75 And you'll see, this is how I have mine set up today. 76 So what I'm going to do is, I'm going to comment out 77 the standard Java home command, which uses that libexec. 78 And I'm going to do an export, JAVA_HOME equals, 79 and then I'm going to paste from the buffer 80 that Graal location. 81 So this will now set my Java home to that Graal location. 82 You'll also notice on my path statement that I am 83 predefining my Java home/bin directory on my path. 84 That way, I always get the Java executables 85 based on my Java home. 86 So that's how I have mine set up. 87 Your mileage may vary based on how you set up your Java home 88 and your path statement, 89 but that's how mine is currently done. 90 I'm going to go ahead and save that file. 91 I'm going to go ahead and open up a new terminal window 92 so that I can pick up that path. 93 So now, if we do an echo on JAVA_HOME, 94 you will see that my Graal location is on the Java home. 95 Likewise, if I echo my path, 96 you'll see that that location is there. 97 So that's all great. 98 Now we can actually do an install. 99 If you're doing Graal installations for things like Ruby, 100 you're going to follow a very similar path, 101 but for this course, the only thing that we need to install 102 into this, using the GU function, is native-image. 103 So we'll go ahead and allow this to run. 104 The fact that you can do the GU indicates 105 that you've got your Java home set up correctly. 106 We'll allow this to run. 107 So now we have everything set on our machine 108 to do our GraalVM development.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.