Java Package NHLstats Import Issue - java

Apologies if this is not allowed. I have been going through the mooc.fi learning java course and seem to be stuck on exercise 13.
The course gives you a pre-built package and asks you to do various tasks with the package.
After downloading the package and running in IntelliJ I am getting the error "java: Package nhlstats does not exist".
I have tried re-naming one "NHLTest" class to "nhlstats" however I still seem to be getting the error. Apologies if this seems a simple question but I can't seem to get my head around Java package structure.
https://imgur.com/qDfRVOj (Screenshot to IDE)
Java: Package nhlstats does not exist

Apologies, I had not set the libraries directory under "File | Project Structure | Libraries" in IntelliJ so I don't think it could find the class to import.

Related

VS Code - The import "#####" cannot be resolved

So, i am running a java project which have many library that are available in the current working directory but VS code seems to not recognize these library and giving out error "The import ###### cannot be resolved" ex: The import org.apache.pdfbox.pdmodel.PDDocument cannot be resolved"
here is the image that might help you to know more about it
This is the package that i am working on :
Here the org/apache is the library contain the class file that are need to be imported and FileArrangement.java is the file having the import statements
Error i have been receiving
this is what VS code is been showing
i really need your help because i really don't have any idea how to correct this
I have checked other projects and they are also showing the same result although the import statements for java classes like . java.util.ArrayList doesn't show any kind of error and i have tried to clean java in VS code it also didn't work
i just need to correct this error of VS code to import the classes that i need
No error on java.util package
Putting the libraries in your current working directory does not work for Java, you need to add them to the classpath.
If you're using maven, that manages the classpath for you.
If not, you can manage it in VS Code by executing the Java: Configure Classpath command from the Command Palette (Ctrl+Shift+P).
You can add dependencies via Referenced libraries under the JAVA PROJECTS panel.
Or use java.project.referencedLibraries setting in settings.json.
For example:
"java.project.referencedLibraries": [
"library/**/*.jar",
"/home/username/lib/foo.jar"
]
Details can be found in configure-classpath and manage-dependencies.

Minecraft Forge 1.16.5 changes since 1.16.4 - compiling error

I am trying to learn Minecraft modding, and while following a tutorial for version 1.16.4, I found that their code did not work, and I presume this is a change to the API, since I am using 1.16.5.
I have looked at both official and unofficial API docs, but these did not provide me any insight. Could anyone point me to a better API reference, or better yet, to a VSCode extension that autocompletes for the most recent Forge API.
Here is the compile error when I ran ./gradlew.bat build with my minimal reproducible example (sorry about the code highlighting, I don't know how to fix it):
C:\Users\eric\Desktop\Programming\Java\Minecraft Mod 1\src\main\java\com\ericl5445\testmod1\core\init\ItemInit.java:1: error: package net.minecraftforge.item does not exist
import net.minecraftforge.item.Item;
^
C:\Users\eric\Desktop\Programming\Java\Minecraft Mod 1\src\main\java\com\ericl5445\testmod1\core\init\ItemInit.java:2: error: package net.minecraftforge.item does not exist
import net.minecraftforge.item.ItemGroup;
^
Here is my full code:
TestMod1.java
ItemInit.java
Any help would really be appreciated!
I do not have an api reference, however I have found that the ItemGroup class is not under net.minecraftforge.item. It is under the package net.minecraft.item.
Your IDE, usually Intellij Idea or Eclipse, should be able to tell you where these classes are located via a search functionality. In Eclipse, you can press Control/Command + Shift + T to bring up a search box with a list of all the classes in your workspace.
The Package You Need To import is net.minecraft.item.Item and net.minecraft.itemGroup,
Not net.minecraftforge.item.Item and net.minecraftforge.itemGroup

Missing package "sun.java2d.cmm" - anyone know where I am supposed to get it?

I've recently pulled down a much newer version of a large project, updated to use a new (well new-er) version of Java (11 instead of 8). However I'm getting an error on the following import:
import sun.java2d.cmm.ProfileDeferralMgr;
And an error of "The import sun.java2d.cmm cannot be resolved"
My various googling, although it produces plenty of blah-blah-blah about sun.java2d.cmm, has not yet told me anything about where I'm supposed to get the package from.
Is this a package that I'm supposed to already "have" and I somehow don't have Eclipse set up to find it? Or is it something that I'm supposed to go "get" and download (if so does anyone know where?)
I'm using 14.0.1 SDK, and I've set it to build target for Java 11 (which is what this project is supposed to be built for as its minspec).
Any help much appreciated!
The package is part of the JDK, but its not supposed to be used publicly. Try this:
% cd jdk-14.0.1/
% bin/jshell
| Welcome to JShell -- Version 14.0.1
| For an introduction type: /help intro
jshell> import sun.java2d.cmm.ProfileDeferralMgr;
| Error:
| package sun.java2d.cmm is not visible
| (package sun.java2d.cmm is declared in module java.desktop, which does not export it)
| import sun.java2d.cmm.ProfileDeferralMgr;
| ^------------^
Interestingly the same error happens in a jdk-11, so I wonder how the project you pulled down builds at all. The answers to this question may help or this.

How to import file from other folder in java?

I have just started learning java, so struggling in very basics. The problem i am facing currently is "cannot find symbol : class Ques". I have resolved this issue when i was accessing package from parent directory through CLASSPATH export. Now problem is i am trying to access sub-directory from sub-driectroy like this:
family.of.adam(has)/
father.java
WifeOne(sub-direc)/wifeone.java,ChildFromWifeOne.java
WifeTwo(sub-direc)/wifetwo.java,ChildFromWifeTwo.java
Now what i am trying to do is from wifetwo.java i am accessing wifeone.java. I have tried importing (wifeone)like this:
import family.of.adam.WifeOne.*;
import WifeOne.*;
In both cases it failed to import and same error occured which i mentioned above.
I have also tried solution provided in this Question but this effects classpath of WifeOne this is what i think because when i -cp method it starts showing errors related to wifeone.
I am using normal texteditor, compiling through terminal and using mac. Kindly brief me what mistake i am doing.
Assume src is your base folder(place you compile and run the program).
src/family/of/adam/FirstWife.java
if so you need to define the package startmetn the fist line of the FirstWife.java file.
package family.of.adam;
Then,If the second java file in the,
src/Main.java
In Main.java file you need to define the import statement for user the FirstWife.java class.
import family.of.adam.FirstWife;

I Cleaned all projects, now when I try to run I get Error: Could not find or load main class?

I wanted to use boilerpipe so I added all .jars to the build path for my project. I did
import de.l3s.boilerpipe.extractors.DefaultExtractor;
and in one of my methods
return(DefaultExtractor.INSTANCE.getText(someURL);
Eclipse is telling me that the import cannot be resolved even though I see DefaultExtractor.java under 'Referenced Libraries'. Someone suggested I clean all of my projects. I did, and now when I try to run I get an error saying:
Error: Could not find or load main class XXXX
How do I make it so I am able to run my code again? And once I do, how can I get boilerpipe to work? Thank you.

Categories

Resources