'How to get PowerShell to play nice with classes in different files?
I am a student trying to complete an assignment in Java. I use VS Code to write, but I use PowerShell to compile and run the code to ensure compatibility outside my IDE. On my laptop I can do this fine running PowerShell from the javafiles location, but as soon as I use my main computer PowerShell complains!
PS C:\FILE LOCATION> javac *.java
Note: Snake.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
PS C:\FILE LOCATION> java Main.java
Main.java:3: error: cannot find symbol
Controller kontroll = new Controller();
^
symbol: class Controller
location: class Main
Main.java:3: error: cannot find symbol
Controller kontroll = new Controller();
^
symbol: class Controller
location: class Main
2 errors
error: compilation failed
Here is some of the code:
All of Main.java ->
class Main {
public static void main (String[] args) {
Controller kontroll = new Controller();
}
}
Some of Controller.java ->
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Controller {
private GUI gui;
private Model modell;
Controller() {
gui = new GUI(this);
modell = new Model(gui);
}
//MORE IRRELEVANT CODE
}
I have seen similar issues here, but they have involved a Mains folder that I don't currently have. I only have the files I have made myself, in a flat structure inside the folder I run PowerShell from. I also tried setting classpath directly in PowerShell by using this line:
-classpath .;
Why would PowerShell complain at home, but run fine on my laptop? How can I troubleshoot this further?
Solution 1:[1]
The issue resolved itself somehow. I suspect OneDrive, but I have no idea what made it happen.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kevin Hansen |