4

here: create_alias & user_defined_functions it is written:

the Sun javac is compiler is used if the file tools.jar is in the classpath. If not, javac is run as a separate process.

How can one specify java class version for H2 Database User-Defined Functions and Stored Procedures - i.e. javac invocation options for the external javac? Can you always force external javac (even if jdk/tool.jar found)?

for example, H2 is built against java 1.5; I am running on java 1.7:

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: 
General error: 
"java.lang.UnsupportedClassVersionError: org/h2/dynamic/NEXT_PRIME : 
Unsupported major.minor version 51.0"; SQL statement:
CREATE ALIAS NEXT_PRIME AS $$
        String nextPrime(String value) {
            return new BigInteger(value).nextProbablePrime().toString();
        }
    $$; [50000-167]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:158)
    at org.h2.message.DbException.convert(DbException.java:277)
    at org.h2.command.Command.executeUpdate(Command.java:234)
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:328)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.UnsupportedClassVersionError: org/h2/dynamic/NEXT_PRIME : 
Unsupported major.minor version 51.0

thanks;

Andrei.

Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
Andrei Pozolotin
  • 897
  • 3
  • 14
  • 21
  • The problem isn't what version H2 is built with. Most likely the problem is the version of the Java compiler used to compile the code (at runtime). H2 starts "javac" (as a process), most likely this is still 1.5 in your environment. Try "javac -version". – Thomas Mueller Jul 12 '12 at 04:55
  • I made sure there is only single java installed system wide; javac -version == javac 1.7.0_05; the server is started like this: [RunH2.java](https://github.com/carrot-garden/sql_mybatis-koans/blob/master/src/test/java/server/RunH2.java); the test is invoked like this: [Koan16.java](https://github.com/carrot-garden/sql_mybatis-koans/blob/master/src/test/java/net/thornydev/mybatis/test/koan16/h2/Koan16.java) – Andrei Pozolotin Jul 12 '12 at 12:00
  • Could you check again that there is no JRE or JDK 1.6 installed in your system? Also, could you post the rest of the stack trace (the 'root cause')? – Thomas Mueller Jul 12 '12 at 14:10

1 Answers1

1

The error message "Unsupported major.minor version 51.0" indicates you have a JDK or JRE 1.6 in your system that is used in some cases. See also the question unsupported-major-minor-version-51-0.

Community
  • 1
  • 1
Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132