Cygwin and Java

前端 未结 5 1612
故里飘歌
故里飘歌 2020-12-17 04:50

I am new to Cygwin. What are the normal steps that are followed when setting Java classpath and all for running programs in Cygwin?

相关标签:
5条回答
  • 2020-12-17 05:42

    It sounds like you need to convert between Windows and Unix-style paths (your Java probably wants Windows paths, your Cygwin talks UNIX). Here is a guide to convert between Unix and Windows paths in Cygwin, using the cygpath util.

    0 讨论(0)
  • 2020-12-17 05:44

    1) Install JDK and check the installation path

    Java binaries may be under "Program Files" or "Program Files (x86)": those white spaces will likely affect the behaviour.

    2) Preliminary info

    In order to set up env variables correctly, I suggest gathering some info before starting: - Open DOS shell (type cmd into 'RUN' box) - go to C: - type "dir /x" and take note of DOS names (with ~) for "Program Files *" folders

    3) Cygwin configuration:

    • go under C:\cygwin\home\
    • open .bash_profile and add the following two lines (conveniently customized in order to match you actual JDK path)
    export JAVA_HOME="/cygdrive/c/PROGRA~1/Java/jdk1.8.0_65"
    export PATH="$JAVA_HOME/bin:$PATH"
    

    Now from Cygwin launch

    javac -version
    

    to check if the configuration is successful.

    0 讨论(0)
  • 2020-12-17 05:45

    I found it easier just to type cmd in cygwin . This allows you to run dos like commands in cygwin . you should be able to start tomcat using the startup.bat file from the terminal

    0 讨论(0)
  • 2020-12-17 05:48

    If I'm not mistaken, Cygwin inherits the Classpath settings from the "normal" windows settings, so if you setup your Classpath within the system properties both Windows and Cygwin should be able to use it.

    0 讨论(0)
  • 2020-12-17 05:52

    I'd suggest taking a look at catalina.sh. This shell script launches java under both unix and cygwin environments. Currently, OpenJDK is not part of the Cygwin installer, and people running Java use a Sun build MS executable. This means the paths must be converted to Windows, and when Java is running it will be the same as if it were launched from a batch file.

    Specifcally, catalina.sh changes these paths using the cygpath program:

    case "`uname`" in
    CYGWIN*) cygwin=true;;
    esac
    
    if $cygwin; then
      JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
      JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
      CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
      CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"`
      CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"`
      CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
      [ -n "$JSSE_HOME" ] && JSSE_HOME=`cygpath --absolute --windows "$JSSE_HOME"`
      JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
    fi
    
    0 讨论(0)
提交回复
热议问题