2

Error on installing pl/java on windows 7 x64 and PostgreSQL 9.0.

CREATE FUNCTION sqlj.java_call_handler()
  RETURNS language_handler AS 'pljava'
  LANGUAGE C;

Error:

ERROR: could not load library "C:/Program Files/PostgreSQL/9.0/lib/pljava.dll": The specified module could not be found.

*** Error ***

ERROR: could not load library "C:/Program Files/PostgreSQL/9.0/lib/pljava.dll": The specified module could not be found. SQL state: 58P01

But I'm sure that pljava.dll exists in C:/Program Files/PostgreSQL/9.0/lib

Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137
Reza
  • 106
  • 1
  • 5
  • 11
  • 1
    Most probably `pljava.dll` depends on some other DLL which is missing. Check with [Dependency Walker](http://www.dependencywalker.com/). – Milen A. Radev Jul 09 '11 at 10:51

2 Answers2

9

I found it's possible to install PL/Java procedural language on PostgreSQL 9.0 64 bit on Windows 7 64 bit (I had same errore message as yours). I see (C:/Program Files path) that you have 64 bit version of PostgreSQL, so you need 64 bit JRE (assuming C:\Program Files\Java\jre6):

  • Download PL/Java 64 bit binary package from pgFoundry (that is, pljava-x86_64-w64-mingw32-pg9.0-1.4.2.tar.gz)
  • Unpack archive to C:\Program Files\PostgreSQL\9.0\share\pljava directory
  • Put pljava.dll into C:\Program Files\PostgreSQL\9.0\lib directory
  • Add into postgresql.conf (data):
custom_variable_classes = 'pljava'
pljava.classpath='C:\\Program Files\\PostgreSQL\\9.0\\share\\pljava\\pljava.jar'
  • Add into PATH (My Computer → Properties → Advanced → Environment Variables):
;C:\Program Files\Java\jre6\bin;C:\Program Files\Java\jre6\bin\server

(you can create another JRE_HOME variable if you like and then write ;%JRE_HOME%\bin;%JRE_HOME%\bin\server)

After that restart PostgreSQL service (postgresql-x64-9.0) and load C:\Program Files\PostgreSQL\9.0\share\pljava\install.sql again. Check:

postgres=# SELECT lanname FROM pg_language;
 lanname
----------
 internal
 c
 sql
 plpgsql
 java
 javau
(6 rows)
Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137
0

I had the exact same error and followed the instructions to a T, but still the same problem. Turns out my PATH statement for the jre included quotes - assumed I needed them because of spaces in the directory names. Removed the quotes from around the jre paths and the lights came on.

Hope this helps!