ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver on OS X Yosemite - jdbc

I use the version of Java 7 that comes with OS X Yosemite. My understanding is that Oracle by now ships Java DB (i.e. Derby) with Java, so perhaps I have it already installed.
I currently get a ClassNotFoundException when attempting Class.forName("org.apache.derby.jdbc.EmbeddedDriver").
Am I supposed to somehow add the driver from a local directory, or do I have to get it extra (e.g. because OS X comes with a JRE but not JDK)?
If the second is true, where should I get it from (i.e. are there any differences between drivers from Apache and Oracle)?

Although Derby (or JavaDB) is installed together with the JDK (at least with Java 7, not sure if they still do with Java 8), it is not part of Java itself. This means you still need to include it in the classpath yourself.

Related

Is there a way to activate earlier Java version in Websphere Application Server 8.5?

When I was installing WAS, there was a prompt alerting me to use Java 8 by default. I aggreed, because back then it wasn't matter which version to use.
Time passed and now I have necessity to use Java 6 in one of my profiles, which is coming with the WAS by default. Since I aggreed to use newer Java, WAS working on Java 8 by default now. I searched in installation repository, but in IBM Installation Manager Java versions I need are greyed out and cannot be installed separately.
Is there a way to install Java 6 alongside Java 8 in WAS, so I could just switch between them in profiles' setting? I tried official repository for Java 6, but it is empty since IBM dropped it's support in April.
P.S. I tried to change variable JAVA_HOME in Websphere profile setting (as well as in system variables) to look at JDK 1.6 I installed separately, but then my profile refuses to start.
Java 6 is no longer supported, so the WAS Installation Manager has likely removed the option to use JDK 6. For WAS 8.5 you can use either Java 7 or Java 8.
This article talks more about Java 6 End of Support:
https://developer.ibm.com/wasdev/blog/2017/10/25/java-6-end-support/

How can I run JRE 7 on Mac 10.6

This may be a longshot, but I NEED to get Java JRE 7 running on Mac 10.6. The official documentation states
Mac OS X System Requirements
Intel-based Mac running Mac OS X 10.7.3 (Lion) or later.
Administrator privileges for installation 64-bit browser
Is there any way I can trick the java JRE 7 into installing itself on OSX 10.6? Is there some community version of a JRE 7?
It can be done, just follow what this answer suggests. I successfully installed JDK 7 update 11 a couple of weeks ago. However I have only used it for some development, and am not sure if it runs e.g. Swing apps without issues.
No.
Easiest is most likely to install virtual box and run Ubuntu inside.
EDIT: The comments indicate that this is not for hobby use but a client. I would personally never base a commercial solution on unsupported software, and I hope it has been made absolutely clear to the client what this can result in.
A better solution might be recompiling your Java program for Java 6 (use the Eclipse compiler with -source and -target) and run it under Java 6. If you cannot do this - as you said NEED - then open a new question asking how to backport that facility to Java 6.

Can Java 7 use Apple Java Extensions?

In order to help Java apps look more like native apps when run on Mac OS X, Apple created the Apple Java Extensions in order to make Java apps behave more like Mac OS X. These allow for things like handling the behavior of the "About" menu and supporting drag and drop onto the application icon.
However, I can't find anything indicating whether or not these extensions are included with Java 7 or even usable with Java 7. It is my understanding that Apple merged their OS X implementation into OpenJDK, but I'm not sure whether these extensions went with it. I do see that the goal for the Mac OS X port of OpenJDK aims to "Include a complete, native Cocoa-based UI Toolkit", but I can't find much about what this entails. Searching the web has not proved very fruitful and I have no idea about if they are compatible with Java 7 or are even included.
So I guess I have three questions:
Will a Mac running Java 7 be able to use the Apple Java Extensions?
Are they included in Java 7, and if not, can I download them to bundle into my app?
Are there any alternatives to these extensions that are Java 7 compatible?
Will a Mac running Java 7 be able to use the Apple Java Extensions?
Yes. They are included both in the Oracle distribution and in OpenJDK. See the second answer here below.
I can't vouch for the complete API as I only need a subset to support drag-drop behaviour on the app icon and on the app frame. I can confirm though this works as expected with OpenJDK 7. No problems on the distribution side either, as the app is on sale on the Mac App Store.
Are they included in Java 7, and if not, can I download them to bundle into my app?
They are included in OpenJDK 7, you can find the sources in /src/macosx/classes/com/apple and supported by Oracle as hinted by the messages and bug fixes readable on the macosx-port-dev mailing list.
They are also included in the Oracle distribution, unjar rt.jar to see them.
You don't have to download anything, just start using them in your editor:
Are there any alternatives to these extensions that are Java 7 compatible?
Not that I know of, but I doubt you need an alternative.

JDK in Mac OS X

I found two JDK in my Mac,
one is in the path:'/System/Library/Java/JavaVirtualMachines/1.6.0jdk'
another is in the path:'/Library/Java/JavaVirtualMachines/1.7.0jdk'
what's the different? why there are two?
The /System/Library/Java/JavaVirtualMachines/1.6.0jdk is the JDK that Apple used to distribute with their operating system. They have since stopped providing a JDK and have left it up to the owner of the Java platform, Oracle, to provide the latest JDK and /Library/Java/JavaVirtualMachines/1.7.0jdk is the JDK provided by Oracle.
The difference is simply the version and vendor (provider) of the JDK. It's perfectly fine to have multiple JDKs on your system.

Java 7 installer for Mac/Windows

I am programming software in Java 7. The users of the software are not all up to date (especially the Mac users). Therefore I need an installer (Windows/OSX) that can be easily integrated with the software installation. There is a normal installer for Windows 7 so I am especially focused on finding one for the Mac. Bonus points if it can check for XCode and other requirements too).
I am thinking another option would be to just use some of the libraries from Java 7 (for example the file-system library). However, I think this might not be possible due to the version number in the compiled classes? I couldn't use a Java 6 compiler to compile these libraries either (because they are Java 7 code).
I don't think I am the only one with this problem. There must be a solution somewhere, but I haven't found it.
Any help would be appreciated.
For the best user experience I would recommend using PackageMaker to create a .pkg file which you can then give to your Mac users. That allows them to do a single click-to-install of your app.
Within the package you would bundle your app archive (JAR file), any necessary resources and two scripts, one to check for the existence of Java 7 on the target system, and the other to install it if not found. I would recommend bundling the latest version of OpenJDK7 with your pkg, at least until an official Java 7 SDK is released for the Mac.
JAva 7 is not yet officially supported on Mac OS X, if you are looking for a JAva 7 installer for mac Os X take a look at openjdk-osx-build project on Google Code.
Update: You shouldn't need Java 7 for what your doing.
A better solution is to use Java 6 + Third party JNI libraries (i.e: JNotify,JavaXT...)
Directory listener in Java using JNotify
as for Last Accessed Date you might need to write tiny bit of Objective-C and pass it back via JNI
JNI Development on Mac OS X
Mac OS X already comes with Java runtime on Snow Leopard (JRE6)
On Lion it will automatically download JRE6 if application needs it's
You can of course download preview release of JDK7 from Oracle, but remember this is preview software there are some parts still not working yet (for example: Java Web Start)
Oracle JDK7u4 Mac OS X Port Developer Preview Release
Edit: Oracle JDK 1.7 Preview Release only supports Mac OS X Lion

Resources