I`m trying to load image with code:
Image image = new Image(AddOrderController.class.getResourceAsStream("/resources/icons/ok_icon.png"));
And I receive exception:
java.lang.NullPointerException: Input stream must not be null
The tree of my project is simple:
When I'm adding ok_icon.png to package controller everything is ok and icon works, but in resources/icons the icon can't be loaded. Can anyone help me how to remake the code?
Since you have src/test/resources as a source folder, the contents of resources will be deployed as part of the application, to the root of the classpath. That means that icons is in the root of the classpath.
You can verify this by checking the contents of the output folder, which I'm guessing is target/classes, using the system file browser (Finder on a Mac, or Windows explorer, or whatever it is called these days). You can verify the output folder in Eclipse by choosing "Project" from the menu, then "Properties", select "Java Build Path", select the "Source" tab, and see what is specified as the "Default output folder".
If the path you supply to getResourceAsStream begins with a leading /, then the path will be interpreted relative to the classpath. So
Image image = new Image(AddOrderController.class.getResourceAsStream("/icons/ok_icon.png"));
should work.
Looks like you have to go one directory up first:
Image image = new Image(AddOrderController.class.getResourceAsStream("../resources/icons/ok_icon.png"));
if that doesn't work neither, check if the two source folders (src) are really the same or if they have a different parent folder
Related
Windows Terminal version
1.12.10732.0
Windows build number
19043.1645
Issue
Forgive me if this has been addressed already somewhere else, but I realized that when Use parent process directory is checked, Command line is able to run testrun.bat which is located in the parent process directory but Icon is unable to access test_icon.ico which is also located in the parent process directory.
Is there a reference (such as %USERPROFILE% is to the home folder) to point to the parent process directory so that I can access the test_icon.ico file? Something along the lines of %PARENTDIRECTORY%\test_icon.ico or otherwise how do I deal with this?
The intent here is to have wt dynamically locate whatever test_icon.ico file that is present in the current parent process directory for the icon or background image settings.
Expected Behavior
test_icon.ico in the Icon field, Loads the .ico file as the icon. Same goes for the background image in the Appearance tab.
Actual Behavior
I get the following error message below...
Found a solution in this article
In the Icon and Background fields, you can reference your files relative to your current working directory:
%__CD__%\relative_path_to_icon_file. In my case it would be %__CD__%\graphics\app_bckgnd.jpg.
I created this Automator app that creates the folders I need to start a new project, but I need to share it with my team, so instead of telling them to open Automator and set the path (doucments/projects/2020/) by themself. I was thinking that maybe they just can paste it in the 2020 folder, run the app and create the project folders in the same folder.
But I don't know how to set a variable with the current path where my Automator App it's saved. Any ideas? Thanks, guys!
My current workflow
To create a new folder in a specific location of the user's home folder, you can use the the special 'location' variables that automator defines. Click the variables tab button in the upper left corner of the automator window to see the full list of available variables...
So, to create a folder hierarchy like the one shown in the link, but at a standardized location in the documents folder, use a flow like the following:
Since Automator doesn't have a specific variable that gives the location of the created workflow app, if you want a path relative to the app's location you'd use a Run AppleScript action and try to path to me command, but every time I've tried it I've received weird errors which make me think that command doesn't work correctly in Automator. I mean, the following ought to produce the correct result, but it consistently errors out:
Maybe you can make it function...
I am used on OSX to use CMD-Shift-g to open a Go to Folder window. What fundamentally does, is to open a file in a location without me using the mouse to navigate to a different directory. I paste the path of a file, like if I am loading a PSD in Photoshop, and I can load the file, independently from where my current directory is pointing at.
Is there an equivalent to this in Windows? Like if I have a file open prompt in Photoshop (or any other windows app, for what matters), that is pointing at my desktop, while my file is in some other location, and I can pass the full path of the file, like I do on OSX with the go to folder window?
I found a "workaround". Windows fundamentally accept in the file name textfield, the full path too; so if you are on desktop for example, and in the file name field you type the full path of the file, it will in fact change the current directory to the full path you pass.
Works in a similar way but without the need to call a window to just change the path.
I have an application that can "serialize" its state as a folder with images. This folder is called, e.g., C:\Temp\MyProject.ImageExplorer and the FileSystem consists of :
C:\Temp\MyProject.ImageExplorer\Pic1.jpeg
C:\Temp\MyProject.ImageExplorer\Pic2.jpeg
...
Can I Configure Windows Explorer in a way, that a Double Click on a folder with my .ImageExplorer "extension" does not open the folder but starts my ImageExplorer.exe with the folder name as command line argument?
Can I modify the C# .Net OpenFile Selector in a way to open these "Folders" including the Filter by extension ?
You can do it but might have issues since the file type is a folder. What I would do is basically make it a uncompressed .ZIP file, You can change the extension to what ever you want so you can associate it with your application like .IZP
You can make your application setup a registry key that associates .IZP with your application and pass the path to the file in as parameter to program.exe path/to/izp/that/user/opened
You might just have to adjust the program to handle reading a container rather than a folder.
I am developing a Jdev extension. The main aim is to change the file contents under selection (applying some rules on the code). I used the FirstSample sample extension to build my application.
I want the filepath of the file i right clicked to invoke the extension
i was able to get the project path using the below code
context.getProject().getURL()
context.getElement().getLongLabel()
provides the file path
I would say that context.getNode().getURL() is the proper way to get a path of the selected node.
Please see
http://docs.oracle.com/cd/E14571_01/apirefs.1111/e13403/oracle/ide/Context.html