6

While trying JShell in Fedora I tried to used snippet transformation shortcut as specified here , but I think It is not working It is showing

Unexpected character after Shift-Tab. Use "i" for auto-import or "v" for variable creation. For more information see:

/help shortcuts

I tried the ways that specified in those messages but still same result

any Ideas or I am doing something wrong?

$javac -version

javac 9

java -version

openjdk version "9"

OpenJDK Runtime Environment (build 9+181)

OpenJDK 64-Bit Server VM (build 9+181, mixed mode)

Here is what I am trying to do :

jshell$ new JFrame

I typed new JFrame and then pressed shift+tab i(holding shift pressed and releasing tab and then pressing i). as per the docs it should show me something like:

0: Do nothing
1: import: javax.swing.JFrame
Choice:

but it is showing

Unexpected character after Shift-Tab. Use "i" for auto-import or "v" for variable creation. For more information see:

instead

optional
  • 3,260
  • 5
  • 26
  • 47

1 Answers1

6

The way the shortcuts work is as follows :

Press Shift+Tab..Release both..Press 'i' or 'v'

--- Use Cases ---

  1. Type a constant for e.g.

    Enter '1' 
    Press Shift+Tab then Press 'v'
    Provide a variable name
    

    enter image description here

    Provide a variable name and you are done with.
    

    enter image description here

  2. Use a java internal class e.g. JFrame

    Enter 'new JFrame'
    

    enter image description here

    Provide your choice
    
Naman
  • 27,789
  • 26
  • 218
  • 353
  • 2
    thanks .It is both shift+tab that we need to release not shift Tab key individual – optional Oct 11 '17 at 14:05
  • 1
    Still not working properly: https://bugs.openjdk.java.net/browse/JDK-8177650 My experience is that it works for classes from the JDK. For jars added on classpath it works sometimes. For added modules it does not work though the packages can be imported using the import keyword. – appsofteng Oct 10 '19 at 21:37