Skip to main content

Portable Eclipse With Java JDK, Tomcat, and PostgreSQL.

How to setup:
Eclipse with Java JDK, Tomcat, and PostrgreSQL
as a portable development environment in Windows.

Download Eclipse IDE for Java EE Developers (eclipse-jee-indigo-SR1-win32.zip) at:
http://www.eclipse.org/downloads/
Unzip in C:\eclipse.

Download Java Platform (JDK) 7u1 (jdk-7u1-windows-i586.exe) at:
http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Unfortunately, it's an exe file so you have to install it, then move the JDK, then uninstall java.
Open explorer to C:\Program Files\Java, then drag the jdk1.7.0_01 folder into C:\eclipse folder.
Edit C:\eclipse\eclipse.ini.
Insert and save this two lines at the VERY TOP:
-vm
.\jdk1.7.0_01\bin\javaw

Download Tomcat 7.0 (under Binary Distributions, Core, as apache-tomcat-7.0.22.zip) at:
http://tomcat.apache.org/download-70.cgi

Unzip in C:\eclipse\apache-tomcat-7.0.22.


Now run eclipse.
It will ask you where to save the workspace; save to C:\eclipse\workspace, and check never to ask again.
Click on workbench (top, right).
Click on servers tab (middle tab at bottom window).
Right click on white area, click new, click server.
Click apache, click on tomcat v7.0 server, click next.
Enter for tomcat installation directory: C:\eclipse\apache-tomcat-7.0.22.
Click next

Now run tomcat by clicking on the start the server icon (round green w/ white triagle) or Ctrl+Alt+R.

Now open a browser to http://localhost:8080/ and it should display an HTTP Status 404 error because it's an empty project.  If you did have apps, it gets deployed here: C:\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps which is created when you first run tomcat.

Check here for a how to load an example project and run it:
http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html
See the section "Import and Test a Sample App".
Basically, download the test-app.zip to your desktop.
In eclipse, go to File | Import | General | Existing Projects into Workspace | Select archive file by browsing to the desktop and select test-app.zip | and click Finish.
Next, right click on Tomcat server (bottom window) | Add and Remove | select test-app from Available column, click Add > to add to the Configured column | click Finish.
And lastly, run Tocmat, and open your browser to http://localhost:8080/test-app/.

To create a war file for deploying your app, right click on test-app in the Project Explorer window on the left of eclipse | Export | War file | and enter or browse destination for the war file | click Finish.



Download postgresql zipped archive (postgresql-9.1.1-1-windows-binaries.zip) at:
http://www.postgresql.org/download/windows/
for the zip archive linked to http://www.enterprisedb.com/products-services-training/pgbindownload.
Click on the win x86-32 icon to download the file.
Unzip in C:\eclipse\pgsql.

Create the start-postgres.bat in C:\eclipse, save it, and run it.  It is setup to initialize the posgresql.
 [start-postgres.bat]


When it is done initializing, edit C:\eclipse\start-postgres.bat.
Rem the initdb line like this: REM "%~dp0\bin\initdb" -U postgres -A trust
Unrem pgAdmin3 line like this: %~dp0\pgsql\bin\pgAdmin3
Save it.

To start postgres, just run C:\eclipse\start-postgres.bat.
Close pgadmin3 normally and the batch file will shutdown postgres.

*April 9, 2014: If you get an error due to a missing dll, you'll need to install Microsoft Visual C++ Distributable Package; version 2012 did not work for me, I had to install version 2010 here http://www.microsoft.com/en-us/download/details.aspx?id=5555

Download the jdbc from http://jdbc.postgresql.org/download.html into C:\eclipse\apache-tomcat-7.0.22\lib.  For jvm 1.7, recommended download: http://jdbc.postgresql.org/download/postgresql-9.1-901.jdbc4.jar

Run eclipse. Click on Help | Install New Software. Select Work With: Indigo - http://download.eclipse.org/releases/indigo | click on the + Database Development | check Data Tools Platform Enablement Extender SDK | Finish.

This example jsp page (transaction.jsp) opens, reads, closes a postgresql.
Create a new jsp page in the test-app project.
 [transaction.jsp]


Run C:\eclipse\start-postgres.bat
Then in eclipse, run tomcat, and open your browser to http://localhost:8080/test-app/transaction.jsp.


In eclipse, you can also connect to the postgres database.
To the top, right of eclipse, click on the Open Perspective icon | Other | Database Development | Ok.
To the left window, right click on Database Connections | New | click on PostgreSQL | change Name: to AAT PostgreSQL | Next
Click on the New Driver Definition icon to the left of the Drivers box.
In the Name/Type tab, click on the PostgreSQL JDBC Driver in the Available driver templates, and change the Driver Name: PostgreSQL9 JDBC Driver.
In the JAR List tab, Remove all the Driver Files, then click Add JAR/Zip, navigate to apache-tomcat-7.0.22\lib and click on our postgres driver (postgresql-9.1-901.jdbc4.jar), and Open.
In the Properties tab, change to these:

Database:  aat
URL: jdbc:postgresql:aat
User name: aat
Password: letmein
check checkbox for Save password
Click OK
Click Finish
If all went well, in the Data Source Explorer window (left of eclipse), under Database Connections you should see the AAT PostgreSQL and below that the aat database which lets you navigate to the aat tables, data, etc.


Update as of Nov 8, 2019
For you portable Eclipse and Java JDK with Tomcat 9

Downloads:

https://www.eclipse.org/downloads/packages/
download the zip file:  https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2019-09/R/eclipse-jee-2019-09-R-win32-x86_64.zip

https://jdk.java.net/13/
download the zip file:  https://download.java.net/java/GA/jdk13.0.1/cec27d702aa74d5a8630c65ae61e4305/9/GPL/openjdk-13.0.1_windows-x64_bin.zip

or the early access build https://jdk.java.net/14/
https://download.java.net/java/early_access/jdk14/21/GPL/openjdk-14-ea+21_windows-x64_bin.zip

https://tomcat.apache.org/download-90.cgi
90.0.27 Binary Distributions Core
download the zip file:  http://mirrors.gigenet.com/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.zip

unzip eclipse
unzip tomcat and jdk inside eclipse folder

add to top of eclipse.ini
-jv
./jdk-13.0.1/bin/javaw

run eclipse

click on Window tab
Show Views
Servers

at bottom add New Server
click Apache
choose server Tomcat 9
Next
Browse
location of tomcat folder
Finish
click on Tomcat 9 server
click Start icon


open browser to http://localhost:8080/



*** when moving location of eclipse folder
make sure you point to your new location for your workspace
make sure to point to your server to new location for tomcat
(click on Console tab will show info when you start tomcat, and will show missing jar error if you haven't done the 2 above)


Comments

Unknown said…
Hi,
C: drive is normally not included in the access rights of a common domain user. C:\Temp is accessible to the user. How can I use C:\Temp\eclipse to get it working?
When I relocated eclipse folder from C:\ to C:\Temp, I get the following error.
The archive: C:/eclipse/apache-tomcat-7.0.61/bin/bootstrap.jar which is referenced by the classpath, does not exist.

What's the fix?

Regards,
MA
Ducusin said…
When you move the location of your eclipse folder, after setting things up, you will need to tell eclipse where your workspace and tomcat are located now.