1

I am trying to set the external classpath in Java 11 JShell using /env --class-path command in windows OS. When the folder does not have space, it is working fine as shown below.

enter image description here

But when the folder is having space, it is giving error as shown below. enter image description here

Could you please help how to resolve this error?

EDIT 1: enclosing the path within a single quote or double quote does not work. enter image description here

SANN3
  • 9,459
  • 6
  • 61
  • 97
Siddarth
  • 351
  • 2
  • 6
  • 20
  • Try ```--class-path 'C:\Users\siddamis\external jars'``` Please learn to copy and paste from your terminal: Please never post images of text. They are not searchable, we cannot copy-paste... Always copy-paste the text and format it properly. – g00se Sep 19 '22 at 09:03
  • @g00se First of all thanks for taking time out to look at my problem. Secondly, I have not posted ten or hundred lines of code that you need to copy. It is just a small path that you could even generalize like C:/folder 1/folder 2 Thirdly I have already tried such a solution and it does not work. Please let me know if you have any concrete solution but please make sure you try it yourself first. No on-the-fly solutions, please. Thanks again – Siddarth Sep 19 '22 at 09:26
  • try forward slashes. --class-path 'C:/Users/siddamis/external jars – anantha ramu Sep 19 '22 at 15:18
  • It won't accept paths with spaces, period. Paths shouldn't have spaces anyway – g00se Sep 19 '22 at 15:18
  • try quotes --class-path 'C:\Users\siddamis\"external ".jar – anantha ramu Sep 19 '22 at 15:19
  • 1
    @g00se please share valid references to your point, period. Paths can have spaces and it is valid. Paths can't have special symbols like colon (:). – Siddarth Sep 20 '22 at 16:10
  • I wasn't able to get a path with spaces to work, despite quoting it in various ways. And btw, I'm just repeating what *you* said was a problem for you – g00se Sep 20 '22 at 17:28
  • @g00se thanks for your efforts in trying to find a solution – Siddarth Sep 21 '22 at 11:32
  • Looks like bug in jshell (does not seem to handle spaces in path on Linux or Windows). Have you checked or submitted to JDK bug database? – DuncG Sep 29 '22 at 10:04

1 Answers1

1

This is known issue JDK-8223941 which applies to all OS if there are spaces in the pathnames. Workaround is to use --class-path from the command line, or paths that don't contain spaces.

DuncG
  • 12,137
  • 2
  • 21
  • 33