File: getsp.java

package info (click to toggle)
libgda5 5.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 75,580 kB
  • sloc: ansic: 495,416; xml: 10,470; yacc: 5,165; sh: 4,442; makefile: 4,093; php: 1,416; java: 1,300; python: 896; sql: 879; perl: 116
file content (61 lines) | stat: -rw-r--r-- 1,648 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Determines that java works correctly and get its libraries path
 * (originally from the R project)
 */ 
public class getsp {
	public static void main(String[] args) {
		if (args!=null && args.length>0) {
			if (args[0].compareTo("-test")==0) {
				System.out.println("Test1234OK");
			}
			else if (args[0].compareTo("-libs")==0) {
				String prefix="-L";
				if (args.length>1) prefix=args[1];

				// we're not using StringTokenizer in case the JVM is very crude
				int i=0,j,k=0;
				String r=null;
				String pss=System.getProperty("path.separator");
				char ps=':';
				if (pss!=null && pss.length()>0) ps=pss.charAt(0);

				// using java.library.path
				String lp=System.getProperty("java.home");
				j=lp.length();
				while (i<=j) {
					if (i==j || lp.charAt(i)==ps) {
						String lib=lp.substring(k,i);
						String suffix="/lib/amd64/server";
						k=i+1;
						if (lib.compareTo(".")!=0)
							r=(r==null)?(prefix+lib+suffix):(r+" "+prefix+lib+suffix);
					}
					i++;
				}

				// using java.home
				lp=System.getProperty("java.library.path");
				j=lp.length();
				i=0;
				k=0;
				while (i<=j) {
					if (i==j || lp.charAt(i)==ps) {
						String lib=lp.substring(k,i);
						k=i+1;
						if (lib.compareTo(".")!=0)
							r=(r==null)?(prefix+lib):(r+" "+prefix+lib);
					}
					i++;
				}

				if (r!=null) System.out.println(r);
			} else if (args[0].compareTo("-ldpath")==0) {
				String lp1=System.getProperty("java.home")+"/lib/amd64/server";
				String lp2=System.getProperty("java.library.path");
				System.out.println(lp1+":"+lp2);
			}
			else
				System.out.println(System.getProperty(args[0]));
		}
	}
}