You are here

Eclipse on a Stick

3 posts / 0 new
Last post
rory.slegtenhorst
Offline
Last seen: 14 years 2 months ago
Joined: 2008-02-04 11:53
Eclipse on a Stick

Hi All,

Lately I have been busy building a lot of Java using Eclipse...
It turns out that running it from the stick is easy enough, but I wanted a small launcher to fit in my PortableApps Menu...
Sad news.. I couldn't get the creator to work for me (maybe it's too simple/advanced (you choose) technology.. I dunno)... but I made it easy on myself and quickly wrote a small launcher ...
... Here's my two cents in delphi Biggrin ...

program EclipsePortable;

uses
SysUtils, IniFiles;

{$R *.res}

const AppName = 'EclipsePortable';
function MessageBox(AHandle: Cardinal; AText, ACaption: PChar; AType: Cardinal): Integer; stdcall; external 'user32.dll' name 'MessageBoxA';
function ShellExecute(hWnd: Cardinal; Operation, FileName, Parameters, Directory: PChar; ShowCmd: Integer): Cardinal; stdcall; external 'shell32.dll' name 'ShellExecuteA';
var
AppFile: string;
CfgFile: string;
IniFile: TIniFile;
USBDrive: string;
begin
CfgFile := ChangeFileExt(ParamStr(0), '.ini');
USBDrive := ExtractFileDrive(ParamStr(0));
if FileExists(CfgFile) then begin
IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
try
AppFile := USBDrive + IniFile.ReadString(AppName, 'EXE', '');
if FileExists(AppFile) then
ShellExecute(0, nil, PChar(AppFile), nil, nil, 1)
else
MessageBox(0, 'Unable to start ' + AppName + '!', AppName, $00000010);
finally
IniFile.Free;
end;
end else
MessageBox(0, 'Unable to find ' + AppName + ' configuration!', AppName, $00000010);
end.

Things I did myself include copying the icon from the eclipse executable, compiling it using delphi 3 to create such a small exe as possible... (I had to use delphi 6 to set the version info properly, but ah well...) At least the code is easy to understand eh Wink
I compressed the end result using upx, and voila a simple starter app that can use a simple ini-file like so:

[EclipsePortable]
EXE=\Eclipse\eclipse.exe

I know I know... it isn't created using nsis... I just couldn't get it to start eclipse from somewhere outside the PortableApps folder... preferring using a ini file to start it up...

If anyone could point me in the right direction to do it in an even better way, I'd like to know...
Ohw ps: after compressing it with upx it was 27.136 bytes...

Cheers,
Rory

rab040ma
Offline
Last seen: 2 weeks 2 days ago
Joined: 2007-08-27 13:35
Which Eclipse package is

Which Eclipse package is this?

MC

rory.slegtenhorst
Offline
Last seen: 14 years 2 months ago
Joined: 2008-02-04 11:53
Uhrmmm...

Uhrmmm...

Any I guess...
As the delphi code explains, it does nothing more than call ShellExecute on the exe that is described in an ini file... it doesn't contain Eclipse itself... launcher only...

In fact... it's close to a generic launcher template one could use... but then it kindof beats the whole idea of PortableApps... (Eclipse + jre being 250Mb)...

Sorry Sad

Log in or register to post comments