osx - Application is using Java 6 from Apple instead of Java 7 from Oracle on Mac OS X? -
i testing current application mac os x has java 7 oracle installed. instead using java 7 oracle, it's using java 6 apple. default scheme output of java -version
showing 7
.
i tried of things mentioned in different sites, unable prepare issue.
java_home
set.
i using mac testing purposes. need guidance on this.
when run eclipse selecting jre 7, runs properly. there nil wrong application. missing on mac os x.
my java scheme environment looks this:
os x version
10.8
/usr/libexec/java_home -v
matching java virtual machines (3): 1.7.0_12, x86_64: "java se 7" /library/java/javavirtualmachines/jdk1.7.0_12.jdk 1.6.0_37-b06-434, x86_64: "java se 6" /system/library/java/javavirtualmachines/1.6.0.jdk/contents/home 1.6.0_37-b06-434, i386: "java se 6" /system/library/java/javavirtualmachines/1.6.0.jdk/contents/home /library/java/javavirtualmachines/jdk1.7.0_12.jdk/contents/home
/usr/libexec/java_home
/library/java/javavirtualmachines/jdk1.7.0_12.jdk/contents/home
echo $java_home
/library/java/javavirtualmachines/jdk1.7.0_12.jdk/contents/home/
java_arch
not set
/library/internet\ plug-ins/javaappletplugin.plugin/contents/home/bin/java -version
java version "1.7.0_12-ea"
ls /library/java/javavirtualmachines
jdk1.7.0_12.jdk
/system/library/frameworks/javavm.framework/commands/java -version
java version "1.6.0_37"
i guess current jdk pointing wrong.
issue
your mac os x application bundle has been created app bundler not compatible oracle's java 7 package. bundler using be, example, jar bundler
provide apple works apple's java 6 scheme packages.
apple has given back upwards java integrated scheme packages java 7 , later. consequence have go oracle java 7 3rd party bundle , application bundle bundle solution. allows create , deploy oracle java 7 based application bundles on mac os x 10.7.3 , onwards.
the underlying technical issue facing apple's native objective-c
based javaapplauncher
binary , format uses in info.plist
working apple's java 6 scheme packages , javaapplauncher
info.plist
combination coming oracle working oracle's java 7 packages.
as using javaapplauncher
supporting apple's java 6 scheme packages, pick apple java 6 scheme bundle installed on mac.
there video, scott kovatch, lead engineer mac os x port of java platform @ oracle talking on devoxx how app bundling oracle java 7 working in great detail.
solutionto create app bundles based mac os x 10.7.3 , onwards based on
oracle's java se 7 (jre 1.7.x) openjdk java se 7 (jre 1.7.x)and above, have utilize oracle's app bundler
lib/appbundler-1.0.jar
containing ant task com.oracle.appbundler.appbundlertask
with oracle's app bundler have selection run packaged app default oracle java 7 bundle installed on mac here:
/library/internet plug-ins/javaappletplugin.plugin/
or oracle java 7 jre inline in packaged application
myjavamacosxapp.app/contents/plugins/
note: there pros , cons both approaches, need lastly 1 own jre if want go apple app store bundled app.
what needs done downloadappbundler-1.0.jar
, move <project>/lib/appbundler-1.0.jar
add next <project>/build.xml
<property environment="env" /> <taskdef name="bundleapp" classname="com.oracle.appbundler.appbundlertask" classpath="lib/appbundler-1.0.jar" /> <target name="bundle"> <bundleapp outputdirectory="dist" name="myjavamacosxapp" displayname="my java mac os x app" identifier="com.example.myjavamacosxapp" shortversion="1.0" applicationcategory="public.app-category.developer-tools" mainclassname="com.example.myjavamacosxapp"> <runtime dir="${env.java_home}" /> <classpath file="dist/myjavamacosxapp.jar" /> </bundleapp> </target>
note: need replace myjavamacosxapp
application data. can find here additional appbundlertask
options, illustration shows how how works in simplest form.
after run the bundle
target ant bundle
find myjavamacosxapp.app
in <project>/dist
directory.
<runtime dir="${env.java_home}" />
element? inlining oracle java 7 bundle (jre)
the ant target above copies oracle java 7 bundle (jre)
java_home
into
myjavamacosxapp.app/contents/plugins
so application bundle totally self contained , not need oracle java 7 bundle (jre) installed on target scheme @ all. can see in next screen shot of such deployed myjavamacosxapp.app
:
wiring default oracle java 7 bundle (jre)
if want utilize default oracle java 7 bundle (jre) installed on application bundle target mac under
/library/internet plug-ins/javaappletplugin.plugin/
you have remove
<runtime dir="${env.java_home}" />
element fromt bundle
task. can see in next screen shot of such deployed myjavamacosxapp.app
:
source of myjavamacosxapp.java
package com.example; import java.awt.*; import javax.swing.*; public class myjavamacosxapp extends jpanel { public myjavamacosxapp() { jlabel versionlabel = new jlabel("java.version=" + system.getproperty("java.version")); jlabel javahomelabel = new jlabel("java.home=" + system.getproperty("java.home")); setlayout(new borderlayout()); add(versionlabel, borderlayout.page_start); add(javahomelabel, borderlayout.page_end); } private static void createandshowgui() { jframe frame = new jframe("myjavamacosxapp"); frame.setdefaultcloseoperation(jframe.exit_on_close); myjavamacosxapp newcontentpane = new myjavamacosxapp(); newcontentpane.setopaque(true); frame.setcontentpane(newcontentpane); frame.pack(); frame.setvisible(true); } public static void main(string[] args) { javax.swing.swingutilities.invokelater(new runnable() { public void run() { createandshowgui(); } }); } }
what if app has multiple jar files? just add together many <classpath file="dist/additional.jar" />
entries need.
note: order of elements in bundle task isn't preserved @ runtime of bundled app. java.class.path
gets built @ runtime native javaapplauncher
reads in *.jar
s myjavamacosxapp.app/contents/java
directory.
just completeness: how info.plist
looks this:
<?xml version="1.0" ?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>cfbundledevelopmentregion</key> <string>english</string> <key>cfbundleexecutable</key> <string>javaapplauncher</string> <key>cfbundleiconfile</key> <string>genericapp.icns</string> <key>cfbundleidentifier</key> <string>com.example.myjavamacosxapp</string> <key>cfbundledisplayname</key> <string>my java mac os x app</string> <key>cfbundleinfodictionaryversion</key> <string>6.0</string> <key>cfbundlename</key> <string>myjavamacosxapp</string> <key>cfbundlepackagetype</key> <string>appl</string> <key>cfbundleshortversionstring</key> <string>1.0</string> <key>cfbundlesignature</key> <string>????</string> <key>cfbundleversion</key> <string>1</string> <key>nshumanreadablecopyright</key> <string></string> <key>lsapplicationcategorytype</key> <string>public.app-category.developer-tools</string> <key>jvmruntime</key> <string>jdk1.7.0_17.jdk</string> <key>jvmmainclassname</key> <string>com.example.myjavamacosxapp</string> <key>jvmoptions</key> <array> </array> <key>jvmarguments</key> <array> </array> </dict> </plist>
important documents reply based on:
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingappsformac.html http://java.net/projects/appbundler/pages/home http://java.net/downloads/appbundler/appbundler.html http://intransitione.com/blog/take-java-to-app-store/ http://www.parleys.com/#st=5&id=2891&sl=37there maintained fork of appbundler itself, many more features , bugfixes.
https://bitbucket.org/infinitekind/appbundler java osx bundle java-7
No comments:
Post a Comment