Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+11 votes

After importing the project to continue working on this at my own computer. I have JRE in my build path as well as the project folder for game_maps in the build path. I try to run the ServerMain file to simulate the different topologies we have implemented and I get the following:

java.io.FileNotFoundException: ..\game_maps\firewalled.json (The system cannot find the path specified)

at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at edu.augustana.csc335.netsim.model.SimNetwork.loadFromFile(SimNetwork.java:109)
at edu.augustana.csc335.netsim.ui.server.ServerViewController.loadNetworkMap(ServerViewController.java:156)
at edu.augustana.csc335.netsim.ui.server.ServerMain.start(ServerMain.java:50)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$166(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$179(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)

Any help would be appreciated!

asked in CSC335_Spring2019 by (1 point)

1 Answer

+6 votes

Curious. Did you change the working directory folder for your launcher for ServerMain?

Try adding this statement to the code right before the error:

String current = new java.io.File( "." ).getCanonicalPath();
System.out.println("Current dir:"+current);

And see what folder your program is executing inside.

As a temporary hack, you can try changing the return statement for ServerMain.chooseNetworkMapFile(...) to:

return mapFile.getAbsolutePath();

However, this isn't a good long-term solution, since it will break things when you do multiplayer across multiple computers, if the installation folder isn't the same...

answered by (5.7k points)
+4

After getting the current path as you stated I now get:
Current dir: C:\Users\Dylan\Desktop\CyberBattleProjectCSC335\CyberBattleNetworkSim

I'm not sure what is to be expected here other than the master project folder...

Also changing the return to the absolute path seemed to work for the time being.

...