@@ -495,79 +495,23 @@ private List<String> getProcessCommandsWithoutArgs() throws IOException, URISynt
495
495
command .add ("-cp" );
496
496
command .add (classpath );
497
497
command .add (className );
498
- System .out .println (command );
499
498
return command ;
500
499
}
501
500
502
- public static List <String > getClassLocations (Class <?>... classes ) {
503
- List <String > locations = new ArrayList <>();
504
- for (Class <?> clazz : classes ) {
505
- String location = getClassLocation (clazz );
506
- if (location != null && !locations .contains (location )) {
507
- locations .add (location );
508
- }
509
- }
510
- return locations ;
511
- }
512
-
513
- private static String getClassLocation (Class <?> clazz ) {
514
- try {
515
- String classResource = clazz .getName ().replace ('.' , '/' ) + ".class" ;
516
- URL location = clazz .getClassLoader ().getResource (classResource );
517
- System .out .println (location );
518
-
519
- if (location != null ) {
520
- String path = extractPath (location );
521
- System .out .println (path );
522
- if (path != null ) {
523
- File file = new File (path );
524
- if (file .isFile ()) {
525
- // If it's a JAR file
526
- return file .getAbsolutePath ();
527
- } else {
528
- // If it's a directory (for .class files)
529
- return file .getParent ();
530
- }
531
- }
532
- }
533
- } catch (UnsupportedEncodingException e ) {
534
- e .printStackTrace ();
535
- }
536
- return null ;
537
- }
538
-
539
- private static String extractPath (URL url ) throws UnsupportedEncodingException {
540
- String path = url .getPath ();
541
- if (path .startsWith ("file:" )) {
542
- path = path .substring (5 );
543
- }
544
- path = URLDecoder .decode (path , "UTF-8" );
545
-
546
- if (path .contains (".jar!" )) {
547
- path = path .substring (0 , path .lastIndexOf (".jar!" ) + 4 );
548
- }
549
-
550
- return path ;
551
- }
552
-
553
501
private static String getCurrentClasspath () throws UnsupportedEncodingException {
554
502
555
503
String modelrunnerPath = getPathFromClass (DeepLearningEngineInterface .class );
556
- getClassLocations (DeepLearningEngineInterface .class );
557
- System .out .println ("AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" );
558
504
String imglib2Path = getPathFromClass (NativeType .class );
559
505
String gsonPath = getPathFromClass (Gson .class );
560
506
String jnaPath = getPathFromClass (com .sun .jna .Library .class );
561
507
String jnaPlatformPath = getPathFromClass (com .sun .jna .platform .FileUtils .class );
562
508
if (modelrunnerPath == null || (modelrunnerPath .endsWith ("DeepLearningEngineInterface.class" )
563
509
&& !modelrunnerPath .contains (File .pathSeparator )))
564
510
modelrunnerPath = System .getProperty ("java.class.path" );
565
- modelrunnerPath = System .getProperty ("java.class.path" );
566
511
String classpath = modelrunnerPath + File .pathSeparator + imglib2Path + File .pathSeparator ;
567
512
classpath = classpath + gsonPath + File .pathSeparator ;
568
513
classpath = classpath + jnaPath + File .pathSeparator ;
569
514
classpath = classpath + jnaPlatformPath + File .pathSeparator ;
570
-
571
515
return classpath ;
572
516
}
573
517
0 commit comments