-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetting-vs-code-java.home-win.html
More file actions
205 lines (189 loc) · 6.94 KB
/
setting-vs-code-java.home-win.html
File metadata and controls
205 lines (189 loc) · 6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<p>
Sometimes (but not always!) the extension that helps VS Code handle Java
projects has trouble finding the Java installation on Windows. We aren’t sure
why this happens, but the following steps work around it:
</p>
<h2 id="find-your-java-installation">Find your Java installation</h2>
<ol type="1">
<li id="a3e7b1">
<a href="#a3e7b1" class="anchor-link" aria-label="Link to this item"></a>
<p>
<strong>Open Windows Explorer</strong>. (You can do this quickly by
holding down the Windows key and pressing E.)
</p>
</li>
<li id="b4f8c2">
<a href="#b4f8c2" class="anchor-link" aria-label="Link to this item"></a>
<p>
In the list of locations on the left of the Explorer window, click
<strong>Local Disk (C:)</strong>.
</p>
<img
src="images/setting-vs-code-java.home-win-local-disk.png"
style="width: 95%"
alt="Windows Explorer screenshot with arrow pointing to the 'Local
Disk (C:)' in the sidebar"
/>
</li>
<li id="c5g9d3">
<a href="#c5g9d3" class="anchor-link" aria-label="Link to this item"></a>
<p>Open <strong>Program Files</strong>:</p>
<img
src="images/setting-vs-code-java.home-win-program-files.png"
alt="Windows Explorer screenshot with arrow pointing to 'Program Files'"
style="width: 75%; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1)"
/>
</li>
<li id="d6h0e4">
<a href="#d6h0e4" class="anchor-link" aria-label="Link to this item"></a>
<p>Open <strong>AdoptOpenJDK</strong>:</p>
<img
src="images/setting-vs-code-java.home-win-adopt-openjdk.png"
alt="Windows Explorer screenshot with arrow pointing to 'AdoptOpenJDK'"
style="width: 75%; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1)"
/>
</li>
<li id="e7i1f5">
<a href="#e7i1f5" class="anchor-link" aria-label="Link to this item"></a>
<p>
You should see a folder here with a name like
<strong>jdk-#####-hotspot</strong>. The exact name may look different than
the screenshot below, but it should start with “jdk.”
<strong>Open that folder</strong>.
</p>
<img
src="images/setting-vs-code-java.home-win-jdk.png"
alt="Windows Explorer screenshot with arrow pointing to 'jdk-14.0.2.12-hotspot'"
style="width: 75%; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1)"
/>
</li>
<li id="f8j9k0">
<a href="#f8j9k0" class="anchor-link" aria-label="Link to this item"></a>
<p>
The address bar at the top of your explorer window should now say
something similar to:
</p>
<blockquote>
This PC → Local Disk (C:) → Program Files → AdoptOpenJDK →
jdk-14.0.2.12-hotspot
</blockquote>
<p>
<strong>Right-click the jdk-####-hotspot item</strong> in the address bar,
then choose <strong>Copy address</strong> from the menu:
<img
src="images/setting-vs-code-java.home-win-copy-address.png"
alt="Windows Explorer screenshot for copying the address to the
'jdk...hotspot' folder"
style="width: 95%; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1)"
/>
</p>
</li>
</ol>
<h2 id="tell-vs-code-where-java-is">Tell VS Code where Java is</h2>
<ol type="1">
<li id="g1h2i3">
<a href="#g1h2i3" class="anchor-link" aria-label="Link to this item"></a>
<p>Open Visual Studio Code.</p>
</li>
<li id="j4k5l6">
<a href="#j4k5l6" class="anchor-link" aria-label="Link to this item"></a>
<p>
Press <strong>ctrl-,</strong> (i.e., hold down the control key and press
the comma key). This should open VS Code's settings window:
<img
src="images/setting-vs-code-java.home-win-vs-code-settings.png"
alt="the VS Code Settings screen"
style="width: 75%"
/>
</p>
</li>
<li id="m7n8o9">
<a href="#m7n8o9" class="anchor-link" aria-label="Link to this item"></a>
<p>
Type <strong>java.home</strong> into the "Search settings" field, then
click the <strong>Edit in settings.json</strong> link below:
</p>
<p>
<img
src="images/setting-vs-code-java.home-win-edit-in-settings.png"
alt="screenshot pointing to 'java.home' and 'Edit in
settings.json'"
style="width: 95%"
/>
</p>
</li>
<li id="p0q1r2">
<a href="#p0q1r2" class="anchor-link" aria-label="Link to this item"></a>
<p>
You should see a <code>java.home": ""</code> line like the one in this
screenshot, with your cursor right inside the empty quotes:
<img
src="images/setting-vs-code-java.home-win-java.home-blank.png"
alt="screenshot of the blank java.home setting"
style="width: 95%"
/>
</p>
<p>
There might or might not be other lines around it. Ignore all that. All
that’s important is that you see that “java.home” line, just like it
appear in the screenshot above.
</p>
</li>
<li id="s3t4u5">
<a href="#s3t4u5" class="anchor-link" aria-label="Link to this item"></a>
<p>
Press <strong>ctrl-V</strong> to paste the path you copied up above in
between the quotes. The result should look very similar to this:
<img
src="images/setting-vs-code-java.home-win-setting-fixed-1.png"
alt="screenshot of the pasted-in address for java.home, with
a squiggly underline indicating a problem"
style="width: 95%"
/>
</p>
</li>
<li id="v6w7x8">
<a href="#v6w7x8" class="anchor-link" aria-label="Link to this item"></a>
<p>
Note the squiggly underline and the red letters after the backslashes. We
need to fix that. Go through what you just pasted and
<strong>change every backslash into two backslashes</strong>. When you are
done, the squiggly underline should disappear:
<img
src="images/setting-vs-code-java.home-win-setting-fixed-2.png"
alt="screenshot of the pasted-in address for java.home"
style="width: 95%"
/>
</p>
</li>
<li id="y9z0a1">
<a href="#y9z0a1" class="anchor-link" aria-label="Link to this item"></a>
<p>Press <strong>ctrl-S</strong> to save your changes to this file.</p>
</li>
<li id="b2c3d4">
<a href="#b2c3d4" class="anchor-link" aria-label="Link to this item"></a>
<p>
Press <strong>ctrl-W</strong> to close settings.json, then press
<strong>ctrl-W</strong> again to close Settings.
</p>
</li>
<li id="e5f6g7">
<a href="#e5f6g7" class="anchor-link" aria-label="Link to this item"></a>
<p><strong>Quit</strong> VS Code.</p>
</li>
<li id="h8i9j0">
<a href="#h8i9j0" class="anchor-link" aria-label="Link to this item"></a>
<p><strong>Open</strong> VS Code again.</p>
</li>
</ol>
<p>
Now return to the instructions for running your first Java project and see if
this fixed the problem. If it still doesn’t work, ask for help.
</p>
<p>
<a href="?step=run-first-java-project#bad-java.home">
<button class="action-btn-enabled action-btn">
Back to running your first Java project
</button></a
>
</p>