Java "package does not exist" error
I am fairly new to Java, and am taking an online course offered by Duke in OOP and Java Programming. The class is run on BlueJ, but I'd like to use IntelliJ. There is a package of helper classes, edu.duke, that I need to use.
If I include the package edu.duke in the same folder as a class I am working on, there are no red squiggles or marks over the import statement; indeed, as you can see from the screenshot, the included classes are easily detected by the editor with a mouse hover. But I still get the "package edu.duke does not exist" error.
Sorry if I'm missing something that should be obvious. The beginning courses are heavy on syntax, and light or nonexistent on things like how to structure dependencies.

Please sign in to leave a comment.
How did you configure the source roots? See https://www.jetbrains.com/help/idea/configuring-content-roots.html.
Are there Point and Shape .java files in the edu.duke package?
If you have .class files there instead of the .java files, you will need to configure the library instead (https://www.jetbrains.com/help/idea/working-with-module-dependencies.html#add-a-new-dependency).
I've tried a dummy project and it seems to work fine:
If the issue persists, please share a sample project via https://uploads.jetbrains.com.
Thanks for the prompt response. The edu.duke file contains .java files; it is provided by the course creators. I have uploaded it here:
Upload id: 2021_08_31_VywrEsbCESVAxK8W (file: edu.zip)
When I just drop it in to src, it behaves as I showed above: The editor easily finds the files, but the compiler can't. I have tried to import it as a dependency, but apparently am not doing so correctly.
Pat Dennis
I'm not sure why it doesn't work for you, I can't reproduce the issue.
I had to add commons-csv library since edu.duke classes depend on it.
Here is the complete working project: https://dl.dropboxusercontent.com/s/50dx5czyxxj1j7s/sample.zip.
Thank you so much for your time. Frankly, much of this is a mystery to me, as I still can't recreate your project (via copying and pasting) to one which will compile. It apparently takes something more that I would need to do from within IntelliJ.
BUT I am nevertheless able to use the actual project you supplied as a template that seems to work for the projects in this course, by just changing the name from "sample" to "Project1," etc.
So that is a but kludgy, but it will work for now.
Thanks again,
Pat Dennis
We can help with the non-working project if you zip and share it at https://uploads.jetbrains.com.
Thank you for the offer. As I said, I'm getting by by modifying what you've already done, but it would of course be better if I knew what I was doing!
Here's what I tried:
I select "Create New Project," and name it Shapes Project.
Then "Make from Template" - this gives me a ShapesProject folder containing: .idea, src (within which is Main) and ShapesProject.iml
Then I paste the edu folder into src.
That's about it. I imagine that the edu folder should somehow be imported rather than pasted in, and I know that you added commons-csv library, which I didn't know how to do.
Uploaded here: Upload id: 2021_09_02_9rTMKJDbsFmNM7k6 (file: ShapesProject.zip)
I'm getting CSVParser errors in this project because the library is missing:
Once I add the library to your project, it builds and runs fine:
Got it! Many thanks for your patience!
Pat Dennis
thanks! it really useful for me2