Tuesday, 16 February 2016

Install Eclipse-Che on Ubuntu server

  • Install jdk1.8+ & set JAVA_HOME

  • Install Docker

  • $ which curl
    $ sudo apt-get update
    $ sudo apt-get install curl
    $ curl -sSL https://get.docker.com/ | sh
    
    If you would like to use Docker as a non-root user, you should now consider
    adding your user to the "docker" group with something like:
    $ sudo usermod -aG docker serveradmin
    
    Remember that you will have to log out and back in for this to take effect!
  • Verify docker is installed correctly

  • $ docker run hello-world
    or
    $ sudo docker run hello-world
    
    This command downloads a test image and runs it in a container.
  • Download eclipse-che installation jar

  • The reason why I download the installation jar (JAR Universal Extractor) instead of directly use docker image with following command is that way isn't work for me. It's always showing some error.
    $ docker run -it -p 1104:8080 codenvy/che
    
  • Install eclipse-che

  • $ sudo mkdir /usr/local/eclipse-che-4.0.0-RC3
    $ sudo chown -R serveradmin:serveradmin /usr/local/eclipse-che-4.0.0-RC3
    $ java -jar eclipse-che-latest.jar 
    

    You should select "/usr/local/eclipse-che-4.0.0-RC3" as target installation dir.
  • Add execute permisson to TOMCAT script

  • $ cd /usr/local/eclipse-che-4.0.0-RC3/tomcat/bin
    $ chmod +x *.sh
    
  • Set CHE_HOME

  • $ vi ~/.bashrc
    
    Add the line to it
    export CHE_HOME=/usr/local/eclipse-che-4.0.0-RC3
    
    Reload
    $ source ~/.bashrc
    
    Create link to /usr/bin
    $ sudo ln -s /usr/local/eclipse-che-4.0.0-RC3/bin/che.sh /usr/bin/che
    
    Now,you can start Eclipse-Che by
    $ che start
    








    Friday, 12 February 2016

    • Get current running class dir path
    • String jarOrBuildClassDir = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
      

      It will return 'build/classes/main' if you run it on IDE

      /Users/demo/workspace/MyDemo/build/classes/main/
      

      It will return the location of 'jar' file which the class archived if you run it in a jar file

      /Users/demo/workspace/MyDemo/install/MyDemo/lib/MyDemo.jar
      
    • Get special resources file path that copy from 'src/main/java/resources/com/demo/test.xsl'
    • URL xslFileURL = getClass().getResource("/com/demo/test.xsl")
      

      It will return 'build/resources/main' if you run it on IDE

      /Users/demo/workspace/MyDemo/build/resources/main/com/demo/test.xsl
      

      It will return the location of 'jar' file which the class archived if you run it in a jar file

      file:/Users/demo/workspace/MyDemo/install/MyDemo/lib/MyDemo.jar!/com/demo/test.xsl