I am unable to access Java classes in the default package from jshell
. I cannot import since the default package has no name and when I try to reference the name then I have an error:
jshell> Test.test(); | Error: | cannot find symbol | symbol:
variable Test | Test.test(); | ^--^
The only solution I found so far is using:
/open Test.java
Is it possible or is it a bug?
Here the code of Test.java
:
public class Test {
public static void test() {
System.out.println("test");
}
public static void main(String[] args) {
Test.test();
}
}
This is not possible. From the docs ,
Code in the default package, which is also known as the unnamed package, can't be accessed from JShell.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.