To use Eclipse from a flash drive, you will have to first copy all the necessary files, JDK and Eclipse files to the Flash drive. And then run the Eclipse.exe file. I am mentioning the steps from the official docs below:
- Copy the Java JDK from your PC to the USB drive. You will find the JDK under C:\Program Files\Java. Usually it is named jdk1.8.0_###, where ### is a three-digit value (e.g., C:\Program Files\Java\jdk1.8.0_181).
- Copy the Eclipse folder distribution to the USB drive. See instructions above for the necessary link to the distribution.
Define the workspace on the USB drive as follows:
- Launch Eclipse (look for eclipse.exe in the Eclipse folder).
- In the “Select a directory as workspace” dialog, use the “Browse...” option to select the USB drive (e.g.,E:).
- Provide a folder name after the drive in "Workspace: ". For example, F:\USBWorkspace (assuming USB drive F:).
- Click on the Launch button.
Define the JRE present on the USB drive as the one to use for projects as follows:
To define the JRE in Eclipse, select Window → Preferences → Java → Installed JREs → Search and locate the JDK folder (e.g., jdk1.8.0_181) you placed in the USB drive. Select the folder and click on the Apply button. This will search for the jre. Make the jre the default by selecting the jre from the list displayed (look for Name, Location, etc.). Make the jre the default one and select "Apply and Close". Notice that while creating a project you might need to specify the particular JRE to use. Just right-click on the "JRE System Library", select Properties → Alternate JRE: → Installed JREs, and the appropriate JRE.
- Add the necessary plugins.
You can also refer to this link.