Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By gimbal2

Thread: The method get(String, String[]) in the type Paths is not applicable for the argument

  1. #1
    johnmerlino is offline Member
    Join Date
    May 2014
    Posts
    56
    Rep Power
    0

    Default The method get(String, String[]) in the type Paths is not applicable for the argument

    I am using Oracle Java 8 in Eclipse working on both Ubuntu and OSX. I have this code:

    Java Code:
    	private static String getConfigDir(){
    		Path configDir = Paths.get(homeDir(), homeConfig(), appName());
    		return configDir.toString();
    	}
    	
    	private static String homeDir(){
    		return System.getProperty("user.home");
    	}
    	
    	private static String homeConfig(){
    		return ".config";
    	}
    	
    	// need to replace with dynamic call
    	private static String appName(){
    		return "MyGateway";
    	}
    But for the method get() of Paths, I get this error in eclipse:

    The method get(String, String[]) in the type Paths is not applicable for the argument


    Yet on the Oracle documentation site, it uses a similar example:

    Path p5 = Paths.get(System.getProperty("user.home"),"logs", "foo.log");

    What might I be doing wrong?
    Last edited by johnmerlino; 06-04-2014 at 05:06 PM.

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: The method get(String, String[]) in the type Paths is not applicable for the argu

    Hi,

    can you give us the import section of your file? And maybe also tell us the exact jdk version your are using.

    Right now it seems that you used some Path.get which is not the one you want. I tested your part and with the java.nio.file import it works fine for me.

    Konrad

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: The method get(String, String[]) in the type Paths is not applicable for the argu

    Okay you are using a Java 8 JDK, but what version of Java is the Eclipse project setup to use? It looks like the variable argument list of the method is not understood, which would mean that a very old version of Java is configured.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    johnmerlino is offline Member
    Join Date
    May 2014
    Posts
    56
    Rep Power
    0

    Default Re: The method get(String, String[]) in the type Paths is not applicable for the argu

    I set the compliance level to 1.7 in eclipse and the error went away.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: The method get(String, String[]) in the type Paths is not applicable for the argu

    Why 1.7 if you're using Java 8 though? Just set the compliance level to the highest possible which should be 1.8. If its not available, you have to setup the proper Java runtime in your workspace. I hope your project is setup to just use the workspace settings.
    kneitzel likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 4
    Last Post: 08-17-2013, 05:20 AM
  2. Argument that references an array of type String
    By semio in forum New To Java
    Replies: 4
    Last Post: 03-11-2012, 02:49 AM
  3. operator undefined for argument type int, String
    By aconti in forum New To Java
    Replies: 8
    Last Post: 05-30-2011, 07:32 AM
  4. Replies: 10
    Last Post: 12-07-2010, 12:29 PM
  5. Replies: 4
    Last Post: 03-03-2009, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •