Dan Dan - 1 year ago 120
Java Question

Running Eclipse from usb

I have put the necessary files on my USB pen drive, the Java Development Kit and the Eclipse files. I have created a .bat file which reads

@echo off

set Path=\32 Bit\jdk32\bin;%Path%

cd "32 Bit\Eclipse"
start eclipse.exe


However when I run the batch, Eclipse launches and brings the error

Eclipse Error

As far as I can tell this is trying to use my old path variable for the JNI Shared Library. Could someone help me with this problem please.

Dan Dan
Answer Source

It turns out there is a really simple solution to this.

Amended .bat file

@echo off

set Path=%~dp032 Bit\jdk32\bin;%Path%

cd "32 Bit\Eclipse"
start eclipse.exe



This works by getting the path of an executing batch file using the command %~dp0.


  • d is the drive (in this case N:\)
  • p is the path (Code\Java\Eclipse Mars\)
  • 0 is the name of the executing batch file

This path N:\Code\Java\Eclipse Mars\32 Bit\jdk32\bin which sets the Java version correctly and removes the error I had above

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download