Use java with MSYS and Cygwin

Use Java_Wrapper (https://ja.osdn.net/projects/javaoncygwin/) to prepare an environment to use Java with MSYS2 and Cygwin.

Place of installation

The installation destination is as follows.

/usr/local/bin

Download java_wrapper

Download Java_Wrapper from Official Site to the installation folder.

Put the Java path in Windows.

Put the path in the environment variable as follows.

--Java_HOME = Folder where the JDK is installed

Edit java_wrapper

The downloaded java_wrapper is a shell script. Since the character code of Java in Windows is encoded in cp932 (Shift-JIS), if it is executed through the path, it will naturally be garbled on MSYS and Cygwin.

So I'll fix it as follows.

-exec "$PROGRAM" $ARGS
+exec "$PROGRAM" $ARGS 2>&1 | iconv -f cp932 -t utf-8

Create a symbolic link

After moving to the installation folder, type the following command.

$ java_wrapper createsymlinks

All executables in *% JAVA_HOME% \ bin * are now executed through java_wrapper.

Try to run

I will actually run it.

$ java
how to use: java [-options] class [args...]
           (When executing a class)
Or java[-options] -jar jarfile [args...]
           (When executing a jar file)
The options include:
    -d32 Use 32-bit data model if available
    -d64 Use 64-bit data model if available
    -server       "server"When selecting a VM
The default VM is server.

    -cp <Directory and zip/Class search path for jar files>
    -classpath <Directory and zip/Class search path for jar files>
Directory to search for class files,
JAR archive and ZIP archive;The list is separated by.
    -D<name>=<value>
Set system properties
    -verbose:[class|gc|jni]
Perform detailed output
    -version Output the product version and exit
    -version:<value>
warning:This feature is deprecated and will be released in detail
It will be abolished.
Make the specified version mandatory for execution
    -showversion Output product version and continue
    -jre-restrict-search | -no-jre-restrict-search
warning:This feature is deprecated and will be released in detail
It will be abolished.
Include user's private JRE in version search/exclude
    -? -help Print this help message
    -Print help on X non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
Enable assertions at the specified particle size
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
Disable assertions at the specified particle size
    -esa | -enablesystemassertions
Enable system assertions
    -dsa | -disablesystemassertions
Disable system assertions
    -agentlib:<libname>[=<options>]
Native agent library<libname>To load. Example: -agentlib:hprof
                  -agentlib:jdwp=with help-agentlib:hprof=See also help
    -agentpath:<pathname>[=<options>]
Load the native agent library with the full pathname
    -javaagent:<jarpath>[=<options>]
Load the Java programming language agent. java.lang.See instrument
    -splash:<imagepath>
Display the splash screen with the specified image
For more information http://www.oracle.com/technetwork/java/javase/documentation/index.See html.

I was able to call Java without garbled characters.

$ javac
how to use: javac <options> <source files>
The available options are:
  -g Generate all debug information
  -g:none Do not generate debug information
  -g:{lines,vars,source}Generate only some debug information
  -nowarn do not raise a warning
  -Print a message about the behavior of the verbose compiler
  -deprecation Prints the location of sources where deprecated APIs are used
  -classpath <path>Specifies where to search user class files and annotation processors
  -cp <path>Specifies where to search user class files and annotation processors
  -sourcepath <path>Specifies where to search the input source file
  -bootclasspath <path>Override bootstrap classpath location
  -extdirs <dirs>Override the location of installed extensions
  -endorseddirs <dirs>Override recommended standard path location
  -proc:{none,only}Controls whether annotation processing or compilation is performed.
  -processor <class1>[,<class2>,<class3>...]The name of the annotation processor to run. Bypass the default detection process
  -processorpath <path>Specifies where to search the annotation processor
  -Generates metadata for reflection in the parameters method parameter
  -d <directory>Specifies where to store the generated class files
  -s <directory>Specifies where to store the generated source files
  -h <directory>Specifies where to store the generated native header files
  -implicit:{none,class}Specifies whether to generate class files for implicitly referenced files
  -encoding <encoding>Specifies the character encoding used by the source file
  -source <release>Maintain source compatibility with the specified release
  -target <release>Generate class files for a particular VM version
  -profile <profile>Check if the API used is available in the specified profile
  -version Version information
  -help Print a summary of standard options
  -Akey[=value]Options passed to the annotation processor
  -X Print a summary of non-standard options
  -J<flag>                   <flag>Pass directly to the execution system
  -Quit compilation if Werror warning occurs
  @<filename>Read from file options and filename


I was able to call javac without garbled characters.

Reference site

Recommended Posts

Use java with MSYS and Cygwin
Use JDBC with Java and Scala.
Use Lambda Layers with Java
Use SpatiaLite with Java / JDBC
Use fast Mapping library MapStruct with Lombok and Java 11
Distributed tracing with OpenCensus and Java
Install Java and Tomcat with Ansible
Use Microsoft Graph with standard Java
Use Git with SourceTree and Eclipse
Use Azure Bing SpellCheck with Java
Use Java 11 with Google Cloud Functions
Output PDF and TIFF with Java 8
Encrypt with Java and decrypt with C #
Monitor Java applications with jolokia and hawtio
Link Java and C ++ code with SWIG
Let's try WebSocket with Java and javascript!
[Java] Reading and writing files with OpenCSV
[JaCoCo (Java Code Coverage)] Use with NetBeans
Java and JavaScript
XXE and Java
[Java] Use Collectors.collectingAndThen
Build and test Java + Gradle applications with Wercker
Try to link Ruby and Java with Dapr
How to use Java framework with AWS Lambda! ??
JSON with Java and Jackson Part 2 XSS measures
I want to use java8 forEach with index
How to use Java API with lambda expression
Use Matplotlib from Java or Scala with Matplotlib4j
Prepare a scraping environment with Docker and Java
Mock and stub with minitest (use RR, WebMock, MiniTest :: Mock)
[JAVA] [Spring] [MyBatis] Use IN () with SQL Builder
KMS) Envelope encryption with openssl and java decryption
Encrypt / decrypt with AES256 in PHP and Java
[Java] Convert and import file values with OpenCSV
[Review] Reading and writing files with java (JDK6)
[Java] How to use Calendar class and Date class
[Java] Align characters even with mixed half-width and full-width characters
Install java with Homebrew
Use ProGuard with Gradle
Getters and setters (Java)
Change seats with java
Solving with Ruby and Java AtCoder ABC129 D 2D array
[Java] Thread and Runnable
Summary of ToString behavior with Java and Groovy annotations
Install Java with Ansible
Compile with Java 6 and test with Java 11 while running Maven on Java 8
Solving with Ruby, Perl and Java AtCoder ABC 128 C
Java true and false
[Java] String comparison and && and ||
Use Puphpeteer with Docker
Use aggregate queries (Count) with Azure CosmosDB Java SDK
Comfortable download with JAVA
Use XVim2 with Xcode 12.0.1
Use CentOS with LXD
[Java] Refer to and set private variables with reflection
Play with Java function nodes that can use Java with Node-RED
Switch java with direnv
Use OpenCV in Java
Java --Serialization and Deserialization
Use ngrok with Docker
[Java] Arguments and parameters