[Solved] No java stub created when trying to import jar. Follow
Hey MPS Community,
I am trying to add a jar file of a test java class to understand how MPS interacts with java classes during runtime. I followed these steps to add it: confluence-jetbrains . and also tried this guide: https://tomassetti.me/how-to-add-jars-and-resources-in-a-jetbrains-mps-project/
However after adding the jar as model root and after adding the jar to the java libraries section (see pictures below) I do not see a "stubs" folder in my solution.
My goal is to be able to use the methods and/or data structures from my KnowledgeBase class during runtime (when editing in the projectional editor). I am not sure if this is the right way so any help would be appreciated. Apart from that, I do not see any folders in MPS in my new solution, but I see the folders and my copied jar in the windows explorer when going to the solution (picture below). I copied the jar next to the .mds file in a new Solution (External).
Any ideas on what might be wrong?
Thank you in advance!
Please sign in to leave a comment.
As for the second question, what you see is a "logical view", which shows MPS logical content of the solution. You don't see anything inside a solution until there are some models in it. That's absolutely fine. If you want to see solution directory's content, use "File System" view instead.
About the original problem. We suppose that the jar has the following layout:
in this case, a model pack1.pack2 will be created with a class MyClass inside. Do you have such a layout? I've just checked that your case works fine for me (model root points to a directory where jar is located, the jar itself marked as sources).
thank you for your answer. I just checked my jar and it doesn't have any packages, but only the .class file and a META-INF folder.
Now I created 2 packages and I can see the stubs model is created! Thank you.
So the problem was in the jar structure, more precise in the problem that I did not have my .class in two packages like Mihail suggested.
Is this documented somewhere? Because I could not find this requirement in the examples listed in my first post. Or is this a standard java thing that I just do not know?