0

Bear with me because I don't know all of the technical term but here is my problem: I am trying to use code from another person which I downloaded onto my computer (Mac OS X Lion). It is from a computer that uses JRE 1.7 and when I try to run it on my version of java (JRE 1.6) it throws errors.

I have downloaded and installed JRE 1.7 multiple times and when I try to add it from my "installed JREs" menu (System/Library/Java/JavaVirtualMachines) it is not even there.

^Might have worded this badly but basically I am having trouble adding JRE 1.7 as my current java runtime environment.

As a last resort I would just like to know how I can use 1.7 code in 1.6 (copying it directly in is still giving errors).

user1801325
  • 101
  • 2
  • 1
    JDK7 will not be under `/System` because it's not, in fact, a bundled system component anymore. – millimoose Nov 05 '12 at 21:11
  • 2
    For what it's worth, installing the Oracle Java 7 JDK made it the (command-line) default for me. Also, the way of using 1.7 code in 1.6 is whapping the person who wrote it to support Java 1.6. If you don't know how to port it, it's outside the scope of an SO answer to explain. – millimoose Nov 05 '12 at 21:12

2 Answers2

1

If you have installed JDK 7 using DMG, check this location exist?

/Library/Java/JavaVirtualMachines/jdk1.7..jdk/Contents/Home

If yes, add a new JRE with this location and it should work.

It's working for me, I have both Java 6 and Java 7 installed in my Macbook.

Pankaj
  • 5,132
  • 3
  • 28
  • 37
0

I've no idea how you install JDK 7 on a Mac, but ...

As a last resort I would just like to know how I can use 1.7 code in 1.6 (copying it directly in is still giving errors).

It is most likely that you are getting exceptions telling you that the classfile version number is incorrect. The classfile version number was incremented between Java 6 and Java 7, and this means that an application compiled for Java 7 won't run on Java 6.

One option which might work is to get the other person to compile the code with "-source 1.6 -target 1.6". However, this will only work if:

  • the code doesn't use any of the new Java 7 syntax extensions, and
  • the code doesn't use any Java 7 specific classes or methods.
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216