Skip to content

Commit

Permalink
change default jdkdlindex.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ystyle committed Oct 29, 2018
1 parent 4f001f5 commit 0a6a4d0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
28 changes: 10 additions & 18 deletions jdkdlindex.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
[
{
"version": "ibm_sdk80",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/vibm_sdk80_x64.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/vibm_sdk80_x64.zip"
},
{
"version": "ibm_sdk71",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/vibm_sdk71_x64.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/vibm_sdk71_x64.zip"
},
{
"version": "1.9.0",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.9_x64.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.9_x64.zip"
},
{
"version": "1.8.0_151",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.8.0_151_x64.zip"
},
{
"version": "1.8.0_111",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.8.0_111_x64.zip"
},
{
"version": "1.8.0_31",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.8.0_31_x64.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.8.0_151_x64.zip"
},
{
"version": "1.7.0_67",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.7.0_67_x64.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.7.0_67_x64.zip"
},
{
"version": "1.6.0_43",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.6.0_43_x64.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.6.0_43_x64.zip"
},
{
"version": "1.8.0_74_x86",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.8.0_74_x86.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.8.0_74_x86.zip"
},
{
"version": "1.7.0_80_x86",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.7.0_80_x86.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.7.0_80_x86.zip"
},
{
"version": "1.6.0_43_x86",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.6.0_43_x86.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.6.0_43_x86.zip"
},
{
"version": "1.5.0_07_x86",
"url": "http://7xo3cg.com1.z0.glb.clouddn.com/jdk1.5.0_07_x86.zip"
"url": "https://github.com/ystyle/jvms/releases/download/jdk/jdk1.5.0_07_x86.zip"
}
]
44 changes: 21 additions & 23 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
package main

import (
"os"
"log"
"github.com/codegangsta/cli"
"github.com/tucnak/store"
"encoding/json"
"errors"
"fmt"
"github.com/ystyle/jvms/utils/jdk"
"os/exec"
"github.com/codegangsta/cli"
"github.com/tucnak/store"
"github.com/ystyle/jvms/utils/file"
"github.com/ystyle/jvms/utils/jdk"
"github.com/ystyle/jvms/utils/web"
"encoding/json"
"log"
"os"
"os/exec"
)

const (
version = "2.0.2"
default_Originalpath = "http://7xo3cg.com1.z0.glb.clouddn.com/2.0/jdkdlindex.json"
version = "2.0.3"
default_Originalpath = "https://raw.githubusercontent.com/ystyle/jvms/new/jdkdlindex.json"
)

type Config struct {
JavaHome string`json:"java_home"`
CurrentJDKVersion string`json:"current_jdk_version"`
Originalpath string`json:"original_path"`
Proxy string`json:"proxy"`
JavaHome string `json:"java_home"`
CurrentJDKVersion string `json:"current_jdk_version"`
Originalpath string `json:"original_path"`
Proxy string `json:"proxy"`
store string
download string
}

var config Config

type JdkVersion struct {
Version string`json:"version"`
Url string`json:"url"`
Version string `json:"version"`
Url string `json:"url"`
}

func main() {
Expand Down Expand Up @@ -136,11 +136,11 @@ func commands() []cli.Command {
return err
}

if !file.Exists(config.download){
os.MkdirAll(config.download,0666)
if !file.Exists(config.download) {
os.MkdirAll(config.download, 0666)
}
if !file.Exists(config.store){
os.MkdirAll(config.store,0666)
if !file.Exists(config.store) {
os.MkdirAll(config.store, 0666)
}

for _, version := range versions {
Expand All @@ -162,8 +162,7 @@ func commands() []cli.Command {
// may consider keep the temp files here
os.RemoveAll(jdktempfile)

fmt.Println("Installation complete. If you want to use this version, type\n\njvms switch", v)
fmt.Println()
fmt.Println("Installation complete. If you want to use this version, type\n\njvms use", v)
} else {
fmt.Println("Could not download JDK " + v + " executable.")
}
Expand All @@ -189,7 +188,7 @@ func commands() []cli.Command {
if file.Exists(config.JavaHome) {
err := os.Remove(config.JavaHome)
if err != nil {
return errors.New("Switch jdk failed, please manually remove "+ config.JavaHome)
return errors.New("Switch jdk failed, please manually remove " + config.JavaHome)
}
}
cmd := exec.Command("cmd", "/C", "setx", "JAVA_HOME", config.JavaHome, "/M")
Expand Down Expand Up @@ -287,7 +286,6 @@ func getJdkVersions() ([]JdkVersion, error) {
if err != nil {
return nil, err
}

var versions []JdkVersion
err = json.Unmarshal([]byte(jsonContent), &versions)
if err != nil {
Expand Down

0 comments on commit 0a6a4d0

Please sign in to comment.