1
0

build-cross-run.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. uname_output="$(uname -s)"
  3. case "${uname_output}" in
  4. Linux*) machine=Linux ;;
  5. Darwin*) machine=Mac ;;
  6. CYGWIN*) machine=Windows ;;
  7. MINGW*) machine=Windows ;;
  8. MSYS*) machine=Windows ;;
  9. *) echo "Unknown system '${uname_output}'" && exit 1 ;;
  10. esac
  11. # If JAVA8_32_HOME is set, use its javac
  12. if [[ -n "$JAVA8_32_HOME" ]]; then
  13. if [[ "$machine" == "Windows" ]]; then
  14. JAVA8_32_HOME=$(cygpath "$JAVA8_32_HOME")
  15. fi
  16. export PATH="$JAVA8_32_HOME/bin:$PATH"
  17. fi
  18. # If JAVA7_32_HOME is set, use its javac
  19. if [[ -n "$JAVA7_32_HOME" ]]; then
  20. if [[ "$machine" == "Windows" ]]; then
  21. JAVA7_32_HOME=$(cygpath "$JAVA7_32_HOME")
  22. fi
  23. export PATH="$JAVA7_32_HOME/bin:$PATH"
  24. fi
  25. echo $PATH
  26. # Show javac version
  27. javac -version
  28. # Compile all .java files
  29. javac *.java
  30. # Check if the compilation was successful
  31. if [ $? -ne 0 ]; then
  32. echo "Error during compilation. Exiting."
  33. exit 1
  34. fi
  35. # Create a manifest file for the jar
  36. echo "Main-Class: CrossRun" > manifest.mf
  37. # Package all .class files into a jar
  38. jar cvfm CrossRun.jar manifest.mf *.class
  39. # Cleanup .class files and manifest file (optional)
  40. rm *.class
  41. rm manifest.mf
  42. echo "Done. CrossRun.jar created."