Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run and compile java code in cygwin

Tags:

java

cygwin

I just installed cygwin and I am wondering how do I compile and run my java code through cygwin?

My java code is at my desktop saved in a file named Java.

like image 834
Luffy Avatar asked Jun 03 '26 08:06

Luffy


1 Answers

Assuming you have Java SDK for Windows installed.

In the simplest case:

  1. Ensure/Add java to PATH in cygwin:

    export PATH=$PATH:"/cygdrive/C/Program\ Files/Java/jdk1.8.0_31/bin/"
    

    (don't forget the backslash after Program)

  2. cd to your desktop:

    cd /path/to/Desktop
    
  3. run java compiler:

    javac HelloWorld.java
    

In complex projects you will need to provide a bunch or arguments to javac to make it compile.

like image 91
Jay Avatar answered Jun 05 '26 02:06

Jay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!