Mercurial > hg > octave-lyh
comparison libinterp/octave-value/ov-java.cc @ 15797:492893b98eef
Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Search current directory in addition to home directory and Octave install directory.
* libinterp/octave-value/ov-java.cc(initial_class_path): Search for
"javaclasspath.txt" for Matlab compatibility. Add search for file
in current directory which overrides other locations.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 15 Dec 2012 17:53:31 -0800 |
parents | 12394261da0f |
children | ac9e34f83522 |
comparison
equal
deleted
inserted
replaced
15796:07231ebb6df3 | 15797:492893b98eef |
---|---|
334 if (jar_exists) | 334 if (jar_exists) |
335 { | 335 { |
336 // initialize static classpath to octave.jar | 336 // initialize static classpath to octave.jar |
337 retval = jar_file; | 337 retval = jar_file; |
338 | 338 |
339 // The base classpath has been set. Try to find the optional | 339 // The base classpath has been set. |
340 // file "classpath.txt" in two places. The users classes will | 340 // Try to find an optional file specifying classpaths in 3 places. |
341 // take precedence over the settings defined in the package | 341 // 1) Current directory |
342 // directory. | 342 // 2) User's home directory |
343 | 343 // 3) Octave installation directory where octave.jar resides |
344 std::string str_filename = "classpath.txt"; | 344 |
345 std::string cp_file; | 345 // The filename is "javaclasspath.txt", but historically |
346 file_stat cp_exists; | 346 // has been "classpath.txt" so both are supported. |
347 | 347 std::string cp_list[] = {"javaclasspath.txt", "classpath.txt"}; |
348 // Try to read the file "classpath.txt" in the user's home | 348 |
349 // directory. | 349 for (int i=0; i<2; i++) |
350 | |
351 std::string home_dir = "~" + sep + str_filename; | |
352 cp_file = file_ops::tilde_expand (home_dir); | |
353 cp_exists = file_stat (cp_file); | |
354 if (cp_exists) | |
355 { | 350 { |
356 // The file "classpath.txt" has been found: add its | 351 std::string filename = cp_list[i]; |
357 // contents to the static classpath. | 352 std::string cp_file = filename; |
358 | 353 file_stat cp_exists; |
359 std::string theClassPath = read_classpath_txt (cp_file); | 354 |
360 retval.append (theClassPath); | 355 // Try to find classpath file in the current directory. |
361 } | 356 |
362 | 357 cp_exists = file_stat (cp_file); |
363 // Try to read a file "classpath.txt" in the package directory. | 358 if (cp_exists) |
364 | 359 { |
365 cp_file = java_dir + sep + str_filename; | 360 // File found. Add its contents to the static classpath. |
366 cp_exists = file_stat (cp_file); | 361 std::string classpath = read_classpath_txt (cp_file); |
367 if (cp_exists) | 362 retval.append (classpath); |
368 { | 363 } |
369 // The file "classpath.txt" has been found: add its | 364 |
370 // contents to the static classpath. | 365 // Try to find classpath file in the user's home directory. |
371 | 366 |
372 std::string theClassPath = read_classpath_txt (cp_file); | 367 cp_file = "~" + sep + filename; |
373 retval.append (theClassPath); | 368 cp_file = file_ops::tilde_expand (cp_file); |
369 cp_exists = file_stat (cp_file); | |
370 if (cp_exists) | |
371 { | |
372 // File found. Add its contents to the static classpath. | |
373 std::string classpath = read_classpath_txt (cp_file); | |
374 retval.append (classpath); | |
375 } | |
376 | |
377 // Try to find classpath file in the Octave install directory. | |
378 | |
379 cp_file = java_dir + sep + filename; | |
380 cp_exists = file_stat (cp_file); | |
381 if (cp_exists) | |
382 { | |
383 // File found. Add its contents to the static classpath. | |
384 std::string classpath = read_classpath_txt (cp_file); | |
385 retval.append (classpath); | |
386 } | |
374 } | 387 } |
375 } | 388 } |
376 else | 389 else |
377 throw std::string ("octave.jar does not exist: ") + jar_file; | 390 throw std::string ("octave.jar does not exist: ") + jar_file; |
378 } | 391 } |