0

I have the same code running on Java 6 and Java 7, but in Java 7 it doesn't work as I expect.

I write in the VM argument:

-Dmy.root=D:\mvobs\S.4.8.600_view\

When I run it with Java 6 everything is OK:

my.root=[D:\mvobs\S.4.8.600_view\\]

but in Java 7 I got:

my.root=[D:\mvobs\S.4.8.600_view]

where does the last slash gone?

I also moved form eclipse 3.4.0 to Juno (in order to work with Java 7)

what can be the problem?

BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

0

I'm not sure where it went but you probably shouldn't rely on it anyway.

To build paths, use new File(String, String) or new File(File, String) because these methods get it right on every OS. So to open a file relative to my.root:

File myRoot = new File( System.getProperty( "my.root" ) );
File file = new File( myRoot, "filename" );
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • In the code I concat it with additional path. It use to wrok but now I need to change the code before concat and to add the slash in the code. I want the same code to work in java 6 and java 7. If in the vm argument i write / everthing works fine in both java 6 & 7. – user2042494 Feb 05 '13 at 09:46
  • @user2042494: Create more `File` objects to build the path. Tedious but safe. – Aaron Digulla Feb 05 '13 at 09:49
  • Something which parses the VM arguments might think that \ is an escape character. That's why `/` works better. – Aaron Digulla Feb 05 '13 at 09:50