ImageView in javaFx is not shown when i run it as webstart or in browser -


i've been trying load image imageview, , works fine when run standalone app, when try run in browser or webstart doesn't shown.

i've tried:

ivfoto = new imageview(new image("file:/c:/users/carlos/desktop/4fbzw.jpg")); 

or

ivfoto = new imageview(new image("file:\\c:\\users\\carlos\\desktop\\4fbzw.jpg")); 

or

ivfoto = new imageview("file:///c:/users/carlos/desktop/4fbzw.jpg"); 

if has idea of i'm doing wrong here, appreciate help!

package image (4fbzw.jpg) in application jar file (in same location class loading image) , reference resource:

ivfoto = new imageview(   new image(     this.getclass().getresource("4fbzw.jpg").toexternalform()   ) ); 

there couple of things wrong image references in question:

  1. hardcoding file: protocol.

    a javafx application packaged jar file, resources application should accessed using jar protocol. using getresource method, resource fetched same protocol used load class referencing resource, automatically use correct protocol find resource , don't need worry detail.

  2. referring local resources on development machine.

    webstart , browser embedded application deployment scenarios used reference applications delivered on network remote client. user of client machine have username or using supported os, unlikely have file located at: c:/users/carlos/desktop. packaging image application , getting location relative application's code, image can found consistently no matter deployed.

  3. file based access violates security sandbox webstart , browser embedded apps

    these kind of deployment modes run applications restricted privileges prevent malicious applications doing bad things (like deleting users files or sending them foreign intelligence service). allow applications run elevated security privileges under these deployment modes, need sign applications , user needs explicitly trust software provided you. in particular case of app, not recommend signing, instead package resources require app , users not need undergo inconvenience of signed app.


see also: where javafx.scene.image.image("flower.png") flower.png?


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -