1

I am making a minecraft server...and I have a IllegalChar error Here is the log:

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 4: file:FOO\server.properties
    at sun.nio.fs.WindowsPathParser.normalize(Unknown Source)
    at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
    at sun.nio.fs.WindowsPathParser.parse(Unknown Source)
    at sun.nio.fs.WindowsPath.parse(Unknown Source)
    at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source)
    at java.io.File.toPath(Unknown Source)
    at com.sukkit.Info.loadProperties(FOO2.java:31)
    at com.sukkit.Sukit.main(FOO.java:17)

Here is the server.properties file:

generator-settings=
allow-nether=true
level-name=world
enable-query=false                       --FOURTH LINE
allow-flight=false
server-port=25565
level-type=DEFAULT
enable-rcon=false
force-gamemode=false
level-seed=
server-ip=
max-build-height=256
spawn-npcs=true
white-list=false
spawn-animals=true
hardcore=false
texture-pack=
online-mode=true
pvp=true
difficulty=1
gamemode=0
max-players=20
spawn-monsters=true
generate-structures=true
view-distance=10
motd=A Minecraft Server

And here is the code:

File extFile = new File("server.properties");//create external file
File inFile = new File(MAINFOO.getCodeBase(*/I HAVE CREATED THIS METHOD IN THE MAIN FOO CLASS*/)+"server.properties");//create internal file
if (!extFile.exists()){
    OutputStream out;
    try {out = new FileOutputStream(extFile);
    Files.copy(inFile.toPath(), out);
    } catch (FileNotFoundException e) {
        Sukit.logE(e.toString());
        Sukit.getLogger().severe("ERROR: FILE IS CORRUPT...PLEASE REDOWNLOAD SUKIT");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Here is the MAINFOO.getCodeBase() method:

public static String getCodeBase() {
    String i = ClassLoader.getSystemResource("server.properties").toString();
    String is[] = i.split("server.properties");
    logD(is[0]);
    return is[0];
}

I do not have a single : in my properties file... HELP

2
  • 2
    You seems to be passing file path containing file:// which is why it is failing, please add the code where you call the load method Commented Jun 23, 2013 at 23:31
  • What is the result of MAINFOO.getCodeBase(*/I HAVE CREATED THIS METHOD IN THE MAIN FOO CLASS*/)+"server.properties") ? Commented Jun 23, 2013 at 23:32

1 Answer 1

2

The problem is not the file. The problem is the file name: file:FOO\server.properties. Notice that at index 4 (character 5), you have a :. Instead, you should just use FOO\server.properties and omit the file:.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.