summaryrefslogtreecommitdiff
path: root/switch_java_version.sh
blob: 15124b55bbba835b2562f5bfc1f1c37ad0ecac10 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

#!/bin/sh
#
#  switch_java_version.sh -- Switches JDK/JRE version under Debian
#
#  XXX  Do not use this script. Use "update-java-alternatives" instead.  XXX
#
#  Copyright (c) 2013 Samuel Lidén Borell <samuel@kodafritt.se>
#  
#  Permission is hereby granted, free of charge, to any person obtaining a copy
#  of this software and associated documentation files (the "Software"), to deal
#  in the Software without restriction, including without limitation the rights
#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#  copies of the Software, and to permit persons to whom the Software is
#  furnished to do so, subject to the following conditions:
#  
#  The above copyright notice and this permission notice shall be included in
#  all copies or substantial portions of the Software.
#  
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#  THE SOFTWARE.
#

setalternative() {
    if update-alternatives --quiet --list "$1" > /dev/null 2>&1; then
        update-alternatives --quiet --set "$1" "$location/$2"
    fi
}

setcommonalternatives() {
    setalternative appletviewer bin/appletviewer
    setalternative appletviewer.1.gz man/man1/appletviewer.1.gz
    setalternative extcheck bin/extcheck
    setalternative extcheck.1.gz man/man1/extcheck.1.gz
    setalternative idlj bin/idlj
    setalternative idlj.1.gz man/man1/idlj.1.gz
    setalternative itweb-settings jre/bin/itweb-settings
    setalternative itweb-settings.1.gz jre/man/man1/itweb-settings.1.gz
    setalternative jarsigner bin/jarsigner
    setalternative jarsigner.1.gz man/man1/jarsigner.1.gz
    setalternative java jre/bin/java
    setalternative java.1.gz jre/man/man1/java.1.gz
    setalternative javac bin/javac
    setalternative javac.1.gz man/man1/javac.1.gz
    setalternative javadoc bin/javadoc
    setalternative javadoc.1.gz man/man1/javadoc.1.gz
    setalternative javah bin/javah
    setalternative javah.1.gz man/man1/javah.1.gz
    setalternative javap bin/javap
    setalternative javap.1.gz man/man1/javap.1.gz
    setalternative javaws jre/bin/javaws
    setalternative javaws.1.gz jre/man/man1/javaws.1.gz
    setalternative jconsole bin/jconsole
    setalternative jconsole.1.gz man/man1/jconsole.1.gz
    setalternative jdb bin/jdb
    setalternative jdb.1.gz man/man1/jdb.1.gz
    setalternative jexec jre/lib/jexec
    setalternative jexec-binfmt jre/lib/jar.binfmt
    setalternative jhat bin/jhat
    setalternative jhat.1.gz man/man1/jhat.1.gz
    setalternative jinfo bin/jinfo
    setalternative jinfo.1.gz man/man1/jinfo.1.gz
    setalternative jmap bin/jmap
    setalternative jmap.1.gz man/man1/jmap.1.gz
    setalternative jps bin/jps
    setalternative jps.1.gz man/man1/jps.1.gz
    setalternative jrunscript bin/jrunscript
    setalternative jrunscript.1.gz man/man1/jrunscript.1.gz
    setalternative jsadebugd bin/jsadebugd
    setalternative jsadebugd.1.gz man/man1/jsadebugd.1.gz
    setalternative jstack bin/jstack
    setalternative jstack.1.gz man/man1/jstack.1.gz
    setalternative jstat bin/jstat
    setalternative jstat.1.gz man/man1/jstat.1.gz
    setalternative jstatd bin/jstatd
    setalternative jstatd.1.gz man/man1/jstatd.1.gz
    setalternative keytool jre/bin/keytool
    setalternative keytool.1.gz jre/man/man1/keytool.1.gz
    setalternative orbd jre/bin/orbd
    setalternative orbd.1.gz jre/man/man1/orbd.1.gz
    setalternative pack200 jre/bin/pack200
    setalternative pack200.1.gz jre/man/man1/pack200.1.gz
    setalternative policytool jre/bin/policytool
    setalternative policytool.1.gz jre/man/man1/policytool.1.gz
    setalternative rmic bin/rmic
    setalternative rmic.1.gz man/man1/rmic.1.gz
    setalternative rmid jre/bin/rmid
    setalternative rmid.1.gz jre/man/man1/rmid.1.gz
    setalternative rmiregistry jre/bin/rmiregistry
    setalternative rmiregistry.1.gz jre/man/man1/rmiregistry.1.gz
    setalternative schemagen bin/schemagen
    setalternative schemagen.1.gz man/man1/schemagen.1.gz
    setalternative serialver bin/serialver
    setalternative serialver.1.gz man/man1/serialver.1.gz
    setalternative servertool jre/bin/servertool
    setalternative servertool.1.gz jre/man/man1/servertool.1.gz
    setalternative tnameserv jre/bin/tnameserv
    setalternative tnameserv.1.gz jre/man/man1/tnameserv.1.gz
    setalternative unpack200 jre/bin/unpack200
    setalternative unpack200.1.gz jre/man/man1/unpack200.1.gz
    setalternative wsgen bin/wsgen
    setalternative wsgen.1.gz man/man1/wsgen.1.gz
    setalternative wsimport bin/wsimport
    setalternative wsimport.1.gz man/man1/wsimport.1.gz
    setalternative xjc bin/xjc
    setalternative xjc.1.gz man/man1/xjc.1.gz
}

case "$1" in
    openjdk6)
        export location="/usr/lib/jvm/java-6-openjdk-amd64"
        setcommonalternatives
        ;;
    openjdk7)
        export location="/usr/lib/jvm/java-7-openjdk-amd64"
        setcommonalternatives
        ;;
    *)
        echo "usage: $0  VERSION" >&2
        echo "" >&2
        echo "Where VERSION can be either openjdk6 or openjdk7" >&2
        ;;
esac