How to ship XulRunner with SWT app? - java

I need to ship a specific version (1.8.1.3) of XulRunner with my SWT app. My current plan is to detect the current platform and download XulRunner to the app data path of that platform. That's no problem, but to what file in that am I supposed to set the XulRunnerPath property to?

Make sure you include it in build.properties. I would suggest you to create a fragment for the SWT like how SWT does it for each platform. You need to set System property org.eclipse.swt.browser.XULRunnerPath to the dll. Please refer to
org.eclipse.swt.browser.Mozilla
static void LoadLibraries () {---}
Fragment:
http://wiki.eclipse.org/FAQ_What_is_a_plug-in_fragment%3F

Related

Override install4j UnixLauncher WM_CLASS property

Is it possible to override the WM_CLASS set by install4j on Linux environments?
At the moment, executing
xprop WM_CLASS
on my application deployed with install4j always returns com-install4j-runtime-launcher-UnixLauncher.
This is a problem when creating proper .desktop files, I do not want to group together all applications deployed with install4j.
I gather this question deals with a similar problem. However, the answer does not work for me. The mentioned sys.ext.windowClass compiler variable is not documented anywhere I can find and as far as I can see it does nothing.
On Linux, window managers group windows and assign the correct icons by using the WM_CLASS property.
This property can be inspected using xprop:
xprop WM_CLASS
To specify which WM_CLASS a .desktop file should affect, you can use the StartupWMClass property in a desktop file:
StartupWMClass=<my-applications-wm-class>
The problem with install4j is that all deployed applications will use
com-install4j-runtime-launcher-UnixLauncher as WM_CLASS.
As Ingo Kegel mentions in his now edited answer to this question, this can be circumvented by setting the WM_CLASS window property explicitly in your Java application using the following code:
String wmClass = ...;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Class<?> toolkitClass = toolkit.getClass();
if (Objects.equals("sun.awt.X11.XToolkit", toolkitClass.getName())) {
Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName");
awtAppClassName.setAccessible(true);
awtAppClassName.set(null, wmClass);
}
If you have preliminary dialogs when your application starts (e.g. for selecting a workspace), it is important that you do this for all dialogs separately.

Change default io-wizard images in an Eclipse RCP 3.x application

Is it possible to change the default images of the import and export wizards in an Eclipse 3.x application? I do not mean the wizard image which can be configured in the wizard extension point but images in the surrounding wizard that shows up when calling for example:
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench()
.getService(IHandlerService.class);
service.executeCommand(ActionFactory.IMPORT.getCommandId(), null);
There is an extension point for changing the default images for standard commands (save, save as, delete etc.): org.eclipse.ui.commandImages. However, I did not found something similar for the images in the import and export dialog (wizard and category icons)
(The application is an Eclipse 3.x RCP application running on Eclipse 4.4 using the compatibility layer.)
Thank you,
Michael
I'm not quite sure which images you mean. For the large images at the top of the wizard there is no support for this.
The Import/Export wizard (org.eclipse.ui.internal.dialogs.ImportExportWizard) gets the images from org.eclipse.ui.internal.WorkbenchImages.
The paths in WorkbenchImages are hard coded to be in the icons directory of the org.eclipse.ui plugin.
The images in the tree part of the wizard come from the individual import/export wizard extension point declaration.
As described in the accepted answer there is no official method to do this but it
is possible via the declareImage of the internal class org.eclipse.ui.internal.WorkbenchImages.
In my initialize of my WorkbenchAdvisor I replaced the shared images in the following way:
#SuppressWarnings("restriction")
public class MyWorkbenchAdvisor extends WorkbenchAdvisor {
...
#Override
public void initialize(IWorkbenchConfigurer conf) {
...
try {
// wizard icon
WorkbenchImages.declareImage(
IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ,
<get image descriptor>, true);
// folder icon
WorkbenchImages.declareImage(
ISharedImages.IMG_OBJ_FOLDER,
<get image descriptor>, true);
}...
This can break with every Eclipse version because I access the internal API but
it solved the problem for me.

Converting string to math expression in android? [duplicate]

Is it possible to reference the javax.script.ScriptEngine library when developing an android application?
If not is there anyway possible to evaluate a javascript expression in android?
For the classes javax.script.ScriptEngine, javax.script.ScriptEngineFactory and so on, you can add the jsr223.jar to your Android project: just copy the .jar file to your libs directory, and add it from Properties->Java Build Path.
These class will allow your JSR 223-compliant engines to compile. You can then do new SomeScriptEngienFactory().getScriptEngine() to get an engine. I've managed to do this with JNLua 1.0.4 and Rhino 1.7R2.
The file jsr223.jar can be downloaded from http://www.java2s.com/Code/Jar/j/Downloadjsr223jar.htm, a direct link is http://www.java2s.com/Code/JarDownload/jsr223/jsr223.jar.zip.
javax.script.ScriptEngine is not a default part of android, but you could easily jar up any libraries you need(assuming the size is reasonable, I'm not sure) and include them in your project.
According to this post, javax.script.ScriptEngine is not available in Android SDK. You can try the steps below to include the library, but the code may not run, even though it will compile.
Using Android Development Toolkit in Windows, I performed the following steps to get javax.script library.
Right-clicked on the project, went to Properties (Project).
Under the Java Build Path, I chose Libraries tab.
Select Add Library located on the middle right of the Tab
Select JRE System Library under Add Library and click Next...
Select Workspace Default JRE (jre 7)
Click Finish.
Click Ok on the Java Build Path to exist project properties.
Javax.script was then loaded.
If you want to evaluate some code in JS in android
1) to your gradle dependencies add (rhino):
compile 'org.mozilla:rhino:1.7R4'
2) write some code like this to get the result of JS evaluation
Context rhino = Context.enter()
// turn off optimization to work with android
rhino.optimizationLevel = -1
String evaluation = "2+2"
try {
ScriptableProject scope = rhino.initStandardObjects()
String result = rhino.evaluateString(scope, evaluation, "JavaScript", 1, null).toString()
} finally {
Context.exit()
}
3) You can write more complex scripts in JS to run in the android app also (functions etc.)

How to get IE or applets to revert back to using old version of installed JRE?

I installed JRE 6 on my existing 1.4.2 causing some applets in IE6 requiring 1.4.2 to stop working, how can i revert this back without uninstalling JRE6?
How do you deploy your applet? I assume you are using a jnlp file descriptor (Java Web Start).
If so, maybe you find this link useful:
http://docs.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/syntax.html
You can use this advice when deploying:
http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html
As far as I know, the standard in deploying applets nowadays is to use the deployJava script AND a jnlp file. This way you can detect the client's jre's using
getJREs()
Choose the appropriate one and then initiate your applet by calling:
runApplet(attributes, parameters, minimumVersion)
Please take in account that depending on the Java Plugin the client runs, above approach might not work. DeployJava gives you an option to handle that
To deploy an applet that runs on the old and new Java Plug-ins,
specify the applet tag attributes and JNLP parameters as shown in the
example below:
var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D',
code:'java2d.Java2DemoApplet.class', archive:'Java2Demo.jar', width:710, height:540} ;
var parameters = {fontSize:16, jnlp_href:'java2d.jnlp'} ;
var version = '1.6' ;
deployJava.runApplet(attributes, parameters, version);
On windows, go into control panel, select the java icon, click on the java tab and then on the view button. This should show you a list of installed runtimes, enable and disable whichever you need.

Setting Java Swing application name on Mac

I'm writing a Java Swing application for the Mac using Java 1.6. I've read a number of tutorials that step you through how to better integrate your Java application with OS X, but there's one thing I haven't been able to get working. I can't get the application name (the first, bolded menu item in the Mac menu bar) to display. By default, the fully-qualified class name of the main class is shown and I can't get it to change.
This site says that you have to set the following property:
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "AppName");
But that doesn't work (I'm running 10.6, so maybe the property name changed?).
When I create a new Java project in XCode (I normally use Eclipse), the name somehow magically gets set! (it starts you out with a runnable, boiler-plate application) I've looked all around the XCode project for how this is done, but I can't figure it out!
My guess is that it only sets the application name if you wrap your Java application up in a Mac *.app package, but was wondering if anyone knew the answer. Thanks.
EDIT: Interestingly, it sets the application name if I package my application in a runnable JAR file, but not if I run it from Eclipse.
You should do the following during app initialization, before GUI is built:
// take the menu bar off the jframe
System.setProperty("apple.laf.useScreenMenuBar", "true");
// set the name of the application menu item
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "AppName");
// set the look and feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UPDATE.
Above code works in Java 1.5, this code may not work in 1.6
For new java see documentation:
Either use -Xdock:name command-line property: -Xdock:name=YourAppName
Or set CFBundleName in information property list file (plist)
On Mac 10.7.5, programatically setting the property will work with with Java 1.6 but not with Java 1.7.

Categories