IntelliJ 2018.3 and JShell with custom classes

Answered

Hello. I'm trying to use JShell in IntelliJ IDEA Community 2018.3, but when I try to run the script, the console returns the following error:

  ERROR: package org.somepackage does not exist

  Rejected import org.somepackage.MyClass

My script looks like this:

import org.somepackage.MyClass;

MyClass m = new MyClass("Test");

System.out.println(m.getName());

I've tried a solution posted in StackOverflow, but with no luck: https://stackoverflow.com/questions/48143960/how-to-import-a-custom-class-in-intellij-jshell-console

Thanks in advance.

1
8 comments

Please share the complete project with the library configured that will reproduce the issue: https://intellij-support.jetbrains.com/hc/articles/206869619.

0
Avatar
Permanently deleted user

Sure. I've uploaded the file through HTTPS. The filename is "JShellTest.zip".

Again, thanks for the help.

0

Library root was set incorrectly, it should point to the default package (2 folders above):

0
Avatar
Permanently deleted user

Worked perfectly. Thank you very much.

0

For me its unusable so. I have a multimodule gradle project and i expect <whole project> puts all classes from all modules and all dependencies into account.

3

We have a related feature request, please follow https://youtrack.jetbrains.com/issue/IDEA-176418. 

-1
Avatar
Permanently deleted user

I have the same issue, I am attaching

the screen where is my Project Structure Library settings and it clearly points to the classes

of module sk.eea.jira.telecom.extension.model.ITs. Can Anybody look into it?

0

Try moving the library out of the target folder. For example, to the "/lib" directory in the project root. 

0

Please sign in to leave a comment.