Newbie to Java/Eclipse having problems with paths in Eclipse. The following code the first line shows no errors in the editor but the second one gives
“The import edu.wpi.first.wpilibj.command.Subsystem cannot be resolved”
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.command.Subsystem;
I’m starting to lose what little hair I have left over this. Seems to build the jar file though I haven’t tried to load this to a roborio yet. Any examples of your working build path settings or other info that might point me to a resolution of this is greatly appreciated. Note this code was created by the RobotBuilder program from Eclipse->WPILib->Run RobotBuilder.
Theoretically, if you’re importing edu.wpi.first.wpilibj.*, you are importing every single file from the wpi library. Possibly trying to import Subsystem throws an error because you’ve already imported it. Try removing the first one or the second one.
File Structure:
edu
wpi
first
wpilibj
…
…
command
Subsystem class
importing things with an asterisk automatically imports everything beneath it. Thus importing everything beneath wpilibj imports Subsystem in addition to many other things. Therefore, you would be importing Subsystem twice, which I think is a problem.
Removing either of the above mentioned lines of code does not seem to resolve the issue. I’m assuming that it’s some project settings issue just don’t have a clue where though.
If this helps I also get these three errors under the Problems tab;
Description Resource Path Location Type
The project cannot be built until build path errors are resolved JavaRobot Unknown Java Problem
Unbound classpath variable: ‘networktables’ in project ‘JavaRobot’ JavaRobot Build path Build Path Problem
Unbound classpath variable: ‘wpilib’ in project ‘JavaRobot’ JavaRobot Build path Build Path Problem
and though I didn’t mention it all references, in any source file, to the wpi classes show in the editor with errors like
“Subsystem cannot be resolved to a type”.
Actually, when you import a package in java, it does not import subpackages. Specifically, if you import edu.wpi.first.wpilibj.*, that will not import the command subpackage or the Subsystem class; it only imports the classes in the wpilibj package itself and nothing from a lower level package.
The wpilib plugin adds some classpath variables to your workspace, so if you’ve deleted yours or have created a new one, you’ll need to add them again.
If you create a new Robot Java Project the wpilib plugin will automatically add the classpath variables. Otherwise, follow the steps below to add them manually:
Open the Preferences window and navigate to: Java > Build Path > Classpath Variables
Add the following classpath variables, substituting <User> with your username:
This is indeed the brute force method to fix this problem - well maybe not as brute as Un-installing Eclispe and Re-installing it. But I have not had a lot of success in getting Eclipse to uninstall completely.
The bigger issue is why this happens at all. My team has two development platforms setup at the same time. Projects created in Eclipse before RobotBuilder was used.
Both worked fine until last week. Now one consistently drops the classpath variables. I used the method shown above to re-assign the paths and this morning the classpath variables for wpilibj and networktables are once more missing. Only on one laptop. The other is still working as before.
We have been developing in parallel on these two laptops and the programming team swears that they did nothing different. Yet one computer has the classpath variables and the other does not.
I’ve started working on using FRCSim in Linux Ubuntu with a Java program… Does anybody know the file location for those classpath JAR files on an ubuntu system?