Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
web:eclipse [2024/05/21 16:25] – [WSL1] Bernard Condrauweb:eclipse [2026/01/29 13:31] (current) – [Setup] Bernard Condrau
Line 12: Line 12:
 <sup>1</sup>[[https://mariadb.com/kb/en/incompatibilities-and-feature-differences-between-mariadb-10-11-and-mysql-8/|MariaDB 10.11 versus MySQL 8.0]] <sup>1</sup>[[https://mariadb.com/kb/en/incompatibilities-and-feature-differences-between-mariadb-10-11-and-mysql-8/|MariaDB 10.11 versus MySQL 8.0]]
  
 +===== WSL Settings =====
 +  - To change the default setting of WSL (WSL1/WSL2) to allow file permissions on mounted Windows drives add the file ''wsl.conf'' with the following content to ''/etc'' in your linux distro:<code>[automount]
 +options="metadata,umask=22,fmask=11"</code>
 +  - Stop wsl from the Windows command line:<code>wsl --shutdown [OR] wsl -t NAME</code>
 +  - Start wsl from the Windows command line:<code>wsl [OR] wsl --distribution NAME</code>
 +  - Check wsl instances from the Windows command line:<code>wsl -l -v</code>
 +
 +===== Install Eclipse IDE on WSL2 =====
 +From the next chapter onwards this guide explains how to use Eclipse IDE under Windows. Installing Eclipse within Debian and running it from Windows through an X-Server has the huge advantage that the file permissions are maintained propberly. This chapter is taken from [[https://gist.github.com/rsenden/7bc96a3e678b60e61c750517ca8de883|Run Eclipse in WSL2]] with changes to adapt to my particular environment, specially that I run WSL2 in mirrored networking mode. To do that, create file ''C:\Users\<user>\.wslconfig'' with the following content:<code>[wsl2]
 +networkingMode=mirrored</code>
 + ==== Setup ====
 +[[https://serverfault.com/questions/218745/disable-ipv6-on-loopback-address-localhost-computer-name|IPv4 over IPv6 on Windows]]
 +
 +Access WSL2 using putty
 +Run Eclipse on WSL2 Ubuntu, displaying the Eclipse UI on VcXsrv running on Windows
 +Connecting to VcXsrv directly from WSL2
 +Using SSH X11 forwarding, with network connection initiated from Windows to WSL2 Ubuntu, which is particularly useful on company laptops that refuse all incoming network connections on Windows.
 +Prerequisites:
 +
 +WSL2 up and running
 +Putty, Plink & PuttyGen installed on Windows
 +WSL2 Ubuntu: Install & configure OpenSSH
 +
 +sudo apt install openssh-server
 +
 +Edit /etc/ssh/sshd_config:
 +
 +  X11Forwarding yes
 +  X11DisplayOffset 10
 +  X11UseLocalhost no
 +sudo ssh-keygen -A
 +
 +sudo service ssh start
 +
 +Auto-start SSH daemon:
 +
 +WSL2 Ubuntu: mkdir -p ~/bin ; echo "sudo service ssh start" >> ~/bin/startup.sh
 +Windows: Create scheduled task that runs on user logon, running C:\Windows\System32\bash.exe with arguments /home/<user>/bin/startup.sh
 +Windows: Configure SSH public key authentication using PuttyGen:
 +
 +See https://www.puttygen.com/#How_to_use_PuTTYgen for general instructions
 +Run PuttyGen
 +Generate new key pair, or convert existing key pair
 +Save private key to ppk file; this will used later when connecting to WSL2 Ubuntu using Putty or PLink
 +Add the SSH public key to ~/.ssh/authorized_keys on WSL2 Ubuntu
 +Windows: Create putty profile to connect to WSL2 Ubuntu:
 +
 +Session
 +Host Name: localhost
 +Port: 22 (or whatever OpenSSH port you configured on WSL2 Ubuntu)
 +Connection -> Data:
 +Auto-login username: <your user name>
 +Connection -> SSH -> Auth:
 +Private key file for authentication: <key file generated by PuttyGen in step #2>
 +Connection -> SSH -> X11:
 +Enable X11 forwarding (if you want to start X11 programs)
 +X display location: 127.0.0.1:0.0 (this should match whatever DISPLAY value is shown in VcXsrv logs)
 +Windows: Install & configure VcXsrv:
 +
 +Download & install https://sourceforge.net/projects/vcxsrv/
 +Copy config.xlaunch as shown below to the Startup folder (Win+R: shell:startup)
 +Launch config.xlaunch to start the X Server manually for now
 +WSL2 Ubuntu: Install Eclipse & prerequisites:
 +
 +sudo apt-get install openjdk-11-jdk
 +sudo apt-get install libgtk-3-0
 +Download and unpack Eclipse for Linux to ~/eclipse
 +Windows: Eclipse shortcut using SSH X11 tunnel:
 +
 +Manually try starting Eclipse from Windows by running the following command:
 +plink.exe -batch -X -i <path to .ppk from step #2> <Ubuntu username>@localhost ~/eclipse/eclipse
 +Copy silent.vbs and plink-silent.cmd (see attached files) to the directory where PLink.exe is installed
 +Create a new shortcut that runs the following command:
 +C:\Windows\System32\cmd.exe /c "C:\<path to plink>\plink-silent.cmd -batch -X -i <path to .ppk from step #2> <Ubuntu username>@localhost ~/eclipse/eclipse"
 +Double-click the shortcut; if all is well you should see the Eclipse UI after a couple of seconds
 +Windows: Eclipse shortcut using direct XServer connection:
 +
 +Add the following lines to ~/.profile on WSL2 Ubuntu (create file if it doesn't yet exist):
 +export DISPLAY=:0
 +export LIBGL_ALWAYS_INDIRECT=1
 +Note that having these lines in .bashrc won't work as .bashrc is only loaded for interactive shells
 +Create a new shortcut that runs the following command:
 +C:\Windows\System32\wsl.exe -u <WSL2 user> -- bash -lc 'nohup ~/eclipse/eclipse' ^& sleep 1
 ===== LAMP with Xdebug ===== ===== LAMP with Xdebug =====
   * Follow [[deb12:lamp|LAMP on Debian 12]]   * Follow [[deb12:lamp|LAMP on Debian 12]]
-  * Review your php.ini:<code>output_buffering=off 
-short_open_tag = On 
-max_execution_time=120 
-max_input_time=150 
-max_input_vars = 2000 
-memory_limit = 512M 
-error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT 
-display_errors=On 
-post_max_size = 32M 
-sys_temp_dir = "/tmp" 
-upload_tmp_dir = "/tmp" 
-upload_max_filesize=128M 
-date.timezone=Asia/Bangkok</code> 
  
-===== WSL (Windows Subsystem for Linux) ===== 
-==== WSL1 ==== 
-  * WSL1 runs networking in ''bridged'' mode 
-  * You do not need to set ''xdebug.client_host'' (Xdebug2: ''xdebug.remote_host'') 
-  * Will work with default configuration settings 
-==== WSL2 ==== 
-  * WSL2 runs networking in ''NAT'' or ''mirrored'' mode 
-  * WSL2: run the following command in PowerShell:<code>New-NetFirewallRule -DisplayName "xdebug" -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))" -Direction Inbound -Protocol TCP -LocalPort 9003 -Action Allow</code> 
-  * Check with:<code>Get-NetFirewallRule -DisplayName "xdebug"</code> 
-  * Check logfile with tail -f /path/to/log/xdebug.log 
-  * [[https://gist.github.com/SomajitDey/68e8cd639e3bf592bded035630cf86ec|How to forward WSL2 port to Windows port and vice versa]] 
 ===== Eclipse IDE ===== ===== Eclipse IDE =====
 +
 +==== PHP ====
 +  * Make sure ''display_errors'' is set to ON in apache's php.ini file and not overridden in the apache VirtualHost file 
  
 ==== Java ==== ==== Java ====
Line 52: Line 114:
   * [[https://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F|How do I increase the heap size available to Eclipse?]]   * [[https://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F|How do I increase the heap size available to Eclipse?]]
  
-==== XDebug for PHP 7.2 ==== 
-To activate the debugger, you need to add the following lines to the bottom of x:/xampp/php/php.ini:<code> 
-[XDebug] 
-zend_extension = "C:\xampp\php\ext\php_xdebug-2.6.1-7.2-vc15.dll" ; IMPORTANT: Windows does not find the dll if the drive letter is missing! 
-xdebug.remote_autostart = 1 
-xdebug.profiler_append = 0 
-xdebug.profiler_enable = 0 
-xdebug.profiler_enable_trigger = 0 
-xdebug.profiler_output_dir = "\xampp\tmp" 
-;xdebug.profiler_output_name = "cachegrind.out.%t-%s" 
-xdebug.remote_enable = 1 
-xdebug.remote_handler = "dbgp" 
-xdebug.remote_host = "127.0.0.1" 
-xdebug.remote_log = "\xampp\tmp\xdebug.txt" 
-xdebug.remote_port = 9000 
-xdebug.trace_output_dir = "\xampp\tmp" 
-xdebug.remote_cookie_expire_time = 36000</code> 
-  * Other options can be left at default values. Check the settings have been recognized by checking phpinfo. 
-  * XAMPP does not contain the correct php_xdebug.dll, download it from  [[https://gist.github.com/odan/1abe76d373a9cbb15bed|here]] and put it into folder x:/xampp/php/ext. 
-  * Make sure you have Visual C++ 2017 installed. 
  
-  * Download and install: [[https://gist.github.com/odan/1abe76d373a9cbb15bed|Installing Xdebug for XAMPP with PHP 7.x]] and [[https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads|The latest supported Visual C++ downloads]] 
-  * Check phpinfo: [[https://xdebug.org/wizard.php|Tailored Installation Instructions]] 
- 
-==== XDebug for PHP 5.6 ==== 
-To activate the debugger, you need to add the following lines to the bottom of x:/xampp/php/php.ini: 
-  [Xdebug] 
-  zend_extension=H:\xampp\php\ext\php_xdebug.dll 
-  xdebug.remote_enable = 1 
-  xdebug.remote_port = 9000 
-  xdebug.trace_output_dir = "\xampp\tmp" 
-Other options can be left at default values. Check the settings have been recognized by checking phpinfo. xampp comes with the correct php_xdebug.dll file already located in x:/xampp/php/ext. 
- 
-=== Links === 
-  * [[https://wiki.eclipse.org/Debugging_using_XDebug|Debugging using XDebug]] 
-  * [[http://www.eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf|XDebug Guide]] 
-  * [[https://xdebug.org/docs/remote|XDEBUG EXTENSION FOR PHP - DOCUMENTATION]] 
-  * [[https://xdebug.org/wizard.php|Xdebug Support: Tailored Installation Instructions]] 
  
 ==== JavaScript ==== ==== JavaScript ====
Line 119: Line 144:
   - Add or Edit **Debug Configurations...**. If you pointed the DocumentRoot to your workspace, then you can leave the URL on "Auto Generate", otherwise you must modify the URL.{{ :web:debug.jpg?100 |Debug Configuration}}   - Add or Edit **Debug Configurations...**. If you pointed the DocumentRoot to your workspace, then you can leave the URL on "Auto Generate", otherwise you must modify the URL.{{ :web:debug.jpg?100 |Debug Configuration}}
   - **Window --> Preferences --> PHP --> Code Style --> Formatter**. Select "PHP Conventions" as active profile.{{ :web:phpconvention.jpg?100 |PHP Formatter}}   - **Window --> Preferences --> PHP --> Code Style --> Formatter**. Select "PHP Conventions" as active profile.{{ :web:phpconvention.jpg?100 |PHP Formatter}}
 +  - **Window --> Preferences --> General --> Editors --> Text Editors**. Uncheck "Use find/replace overlay" (see [[https://stackoverflow.com/questions/79012836/eclipse-2024-09-is-there-a-way-to-get-the-old-find-replace-window-back|Eclipse 2024-09 Is there a way to get the old Find/Replace window back?]])
   - If you have existing projects   - If you have existing projects
     * either select the project directory as workspace when first starting up the new eclipse, or     * either select the project directory as workspace when first starting up the new eclipse, or