Would it be legal to decompile and/or reverse engineer a commercial java JAR file to view the inner workings of a library in order to write original code for use with the library in the EU or UK?
IANAL; If this is done by a company, you need to consult a lawyer that specializes in the field of computer law before taking any action.
Most reverse engineering restrictions actually come from the EULA/Terms of service and other contractual binding agreements between the software provider and the user.
Often times Clean room methodologies are used to circumvent any limitations imposed by the software provider. That is where the reverse engineer(s) create a so-called "requirements document" and avoid any code/design tasks, which are performed independently by designated developers whom never performed reverse engineering on target or related products. That way there was no reverse engineering done to a program in the process of producing the "original code" of the replica.
Because no knowledge of the original invention is used while creating the replica implementation (note the subtle difference, as knowledge is used while defining the requirements) the clean room approach is a valid approach to circumvent copyright infringement but cannot be bypass patent law.
According to Wikipedia EU Directive 2009/24, is the most relevant to the question of legality of reverse engineering under EU laws. Keep in mind any contractual agreements with the software company will also affect the legality of reverse engineering their software (and such actions are usually explicitly forbidden there).
This is the excerpt from EU Directive 2009/24:
(15) The unauthorised reproduction, translation, adaptation or transformation of the form of the code in which a copy of a computer program has been made available constitutes an infringement of the exclusive rights of the author. Nevertheless, circumstances may exist when such a reproduction of the code and translation of its form are indispensable to obtain the necessary information to achieve the interoperability of an independently created program with other programs. It has therefore to be considered that, in these limited circumstances only, performance of the acts of reproduction and translation by or on behalf of a person having a right to use a copy of the program is legitimate and compatible with fair practice and must therefore be deemed not to require the authorisation of the right-holder. An objective of this exception is to make it possible to connect all components of a computer system, including those of different manufacturers, so that they can work together. Such an exception to the author's exclusive rights may not be used in a way which prejudices the legitimate interests of the rightholder or which conflicts with a normal exploitation of the program.
This EFF FAQ is also a good start, although I think it mostly addressed USA laws, some of the recommendations are of value anywhere around the globe.