22

How can I run Oracle SQL Developer on a version of Java it supports (1.6) while running Java 1.7 for everything else?

I can install both JDK's on my system, but I'm concerned with changing environment variables and having it affect more than just SQL Developer. Curious if there's elegant solutions to this.

I am having issues with SQL Developer (running off JDK 1.7) only returning 50 rows. <-- Feel free to address this specific issue as well. EDIT: The problem is not that it returns only 50 rows, this is standard, the problem is the inability to scroll down to see more rows on demand.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Xonatron
  • 15,622
  • 30
  • 70
  • 84
  • **UPDATE** Oracle SQL Developer Release 4 [is out now](http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html). This release supports JDK 7 and above. – informatik01 Dec 19 '13 at 15:55

7 Answers7

33

Just install Java7 as the default JDK in your system.

You can tell SQL Developer to use a specific JDK by editing the file sqldeveloper/bin/sqldeveloper.conf and add the line:

SetJavaHome /path/to/jdk

If you are on Windows, you need to specify a correct Windows path of course:

SetJavaHome c:\Java\jdk16

Update after two comments:

The above answer was added when SQL Developer 3.x was the current version. Apparently this does not work any longer for SQL Developer 4.x. It seems that SQL Developer 4.0 just scans the PATH to find a suitable JRE

  • Worked perfectly! For the record I was able to install JDK 1.6 after having installed JDK 1.7. I just put them next to each other. The installation doesn't set any environment variables, so all environment variables set are left pointing to JDK 1.7. And now, after this change, SQL Developer points to JDK 1.6. Perfect! :) – Xonatron Nov 22 '11 at 20:47
  • 1
    Has anyone found an Oracle bug reference for the root cause behind this yet? (The scrolling past 50 rows?) – ziesemer Dec 14 '11 at 19:17
  • 7
    As an additional note: the location of JDK is often configured during installation, and may be found on Windows: `%APPDATA%\\\product.conf`; on Unix/Linux/Mac/Solaris: `$HOME/.//product.conf`. The property used to set JDK path is the same, i.e. *SetJavaHome*. – informatik01 Dec 19 '13 at 15:48
  • @AdamArold: define "not working". It does work for me an apparently many other people –  Apr 14 '14 at 10:57
  • I do as detailed in your answer and it still uses the java set in my `JAVA_HOME`. – Adam Arold Apr 14 '14 at 10:58
  • @AdamArold: which SQL Developer version? I think there have been some changes in the last 3 years (mainly that SQL Developer now requires Java7 if I'm not mistaken) –  Apr 14 '14 at 11:03
  • 1
    I have the same issue as @AdamArold, version 4.0.1 does not use the value set in `SetJavaHome`. In fact, I have no idea where sqldeveloper is getting the path to the JDK, since I have no `JAVA_HOME` environment variable and the path in `SetJavaHome` is being ignored. – Justin Skiles Apr 21 '14 at 13:08
  • 1
    @JustinSkiles: I traced the start of SQL Developer using [ProcessMonitor](http://technet.microsoft.com/de-de/sysinternals/bb896645) and it seems that SQLDeveloper simply scans the `PATH` for a valid JRE. –  Apr 21 '14 at 13:32
  • @a_horse_with_no_name, thanks man. And now I learned to use ProcessMonitor! Much appreciated. What's annoying though is that the error message on startup of the application directs me to edit the `SetJavaHome` variable, but it's clearly ignored! – Justin Skiles Apr 21 '14 at 13:33
  • 9
    For Version 4.0.2.15 the Windows configuration file containing `SetJavaHome` is `%APPDATA%\sqldeveloper\1.0.0.0.0\product.conf` – WhiteKnight May 12 '14 at 10:40
  • After 'SetJavaHome' /path/to/jdk on Windows 8.1 64 bit for **sqldeveloper-4.0.2.15.21** is complete, delete **AppData\Roaming** _SQLDeveloper_ directories. – yW0K5o Aug 25 '14 at 14:05
11

The location of JDK is configured when the SQL developer is first run.

If you need to change the jdk version, once already set in the first run, it can be changed in -
Windows: %APPDATA%\<product-name>\<product-version>\product.conf
Unix/Linux/Mac/Solaris: $HOME/.<product-name>/<product-version>/product.conf

SetJavaHome property needs to be changed and then SQL Developer is to be started.

punita.gosar
  • 400
  • 3
  • 8
3

SQL developer always returns the first 50 rows initially; you might be able to just scroll down the resultset to get the next rows, i.e. it sort of fetches them on demand (from a UI perspective anyway)?

Brian
  • 6,391
  • 3
  • 33
  • 49
  • Ok, I thought this might be the case. Does it actually modify the query to be "rownum <= 50"? Curious if it taxes the DB even though it only shows 50 rows. Next, the problem I have is that I cannot scroll the DB downward to show more rows on demand. I'll update my question to reflect this new knowledge. – Xonatron Oct 24 '11 at 13:52
  • No it won't be adding an explicit rownum constraint, I am guessing it'll be in the internals of SQL Developer where the full resultset is pulled back but the rows provided to the UI are managed in an intelligent manner. Example - if I run a long query that takes 2 mins to return the first 50 results, the next 50 get dislayed via scrolling in a second or so, so it's definitely *not* querying the DB afresh each time. – Brian Oct 24 '11 at 14:11
  • Btw are you sure SQL Developer's running with your Java 7, have you confirmed this via *Help* | *About* and then then *Version* tab? – Brian Oct 24 '11 at 14:15
2

With regards to this issue on only getting 50 rows. Try this:

  • click on 1 of the result rows in the result set
  • hold CTRL, click END key.

That worked for me to get the rest of the rows shelled into the window.

I am an Oracle SQL Developer in Fedora Core 17 desktop and java version "1.7.0_07"

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
Corey S.
  • 21
  • 1
1

You could update file

SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sqldeveloper-Darwin.conf

and switch to JDK 1.7 for SQL Developer on Mac OS X. Change the line to:

SetJavaHome /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

kafeitu
  • 21
  • 5
0

I am the poster of the question, and I just wanted to note that I recently ran into a problem with running Eclipse and Tomcat servers where there was a timeout issue that was caused by using two different versions of Java on my system (1.6 for SQL Developer and 1.7 for everything else) OR was caused by running Java 1.7 alone. I solved this issue by running 1.6 for everything. Just a heads up.

See Change Tomcat Server's timeout in Eclipse for more details.

Community
  • 1
  • 1
Xonatron
  • 15,622
  • 30
  • 70
  • 84
0

If you want everything else to run in Java 1.7, I'm assuming that you want that to be the default called by the java command. So, make sure that the java command points to that file. How you actually do that is OS-dependent, of course; for OS X/Linux you can check with which java, and find all the available versions of Java with update-alternatives --display java, and switch with update-alternatives --config java. For Windows, make sure the correct executable is in the PATH environment variable, as described here for XP.

Then, if you want to run a program with a specific VM, instead of the java command you can use the full path to the executable you want, e.g. /usr/lib/jvm/java-6-sun/jre/bin/java myApplication for Linux, and similar for Windows. You'll probably want to do something to make this easier on yourself such as setting up an alias in Linux or maybe another environment variable in Windows.

Edit

For example, in Windows you could do C:\Java\jdk16\java C:\path\to\Oralce\SQLDev\sqld, substituting the paths as appropriate. This assumes that Oracle provides a jar or something that Java can run, and not just a compiled .exe.

andronikus
  • 4,125
  • 2
  • 29
  • 46
  • So, maybe you already answered this, but how do I set just Oracle SQL Developer to run off my JDK 1.6 install (on Windows)? I'm assuming it uses environment variables like maybe JAVA_HOME to know where the JDK is, but other programs use it too. – Xonatron Oct 24 '11 at 14:00
  • I don't know if there's a way to make SQL Dev run in Java 6 from inside the program itself; you'd run it by opening a command line and running `C:\Java\jdk16\java C:\path\to\Oralce\SQLDev\sqld`, substituting the paths as appropriate, of course. Once you figure out the right command, I think you can make a new shortcut and paste the command in there. I don't have a Windows box available right at the moment though. – andronikus Oct 24 '11 at 16:59