Blackberry runtime error: FRIDG: could not find img/logo.png - java

I recently had to prepare a BB app for submission to the BB app world, but I have an issue when running the app. Basically, I've created a new Blackberry project, using the "use existing source" option to point to the sources I've got from the developer that actually developed this app. Building the application just works, but when I want to start the app it immediately quits with a NullPointerException.
When debugging the application, the debugger halts at the following line:
Bitmap bitmaplogo = EncodedImage.getEncodedImageResource("img/logo.png").getBitmap();
With the following error:
[0.0] FRIDG: could not find img/logo.png
I do have an img/logo.png, which is located in /res/img/logo.png. Attempts of specifying the path as "res/img/logo.png", "/res/img/logo.png", "logo.png" have not worked. I personally don't think that's the issue here, this exact code base works perfectly for another developer. I'm more inclined to start looking into tooling, JDK/JRE versions, project settings. Maybe resource files should be explicitly included in the build?
Some other information:
My Blackberry project uses Blackberry JRE 5.0.0 as the JRE system library
I have Oracle Java SDK 6 Update 26 installed
Using Blackberry Java Plugin for Eclipse 1.3.0
On Windows XP SP2
Has anyone encountered the same issue before?

Filenames and extensions are case sensitive. logo.png and logo.PNG are different files from application's point of view. So, be careful with naming files and folders.
The root folder for images you get in your application is the root folder of your source files package.
For instance, if you have the following folder structure:
YourProject
src\
com\
company\
etc\
img\
Then the root folder for your images will be: YourProject\src
Image files located in YourProject\img folder are invisible for your application code, unless img folder is located in YourProject\src and the full path is:
YourProject\src\img
and your image file has the full path like that:
YourProject\src\img\logo.png
In this case you can load the image via specifying it's path: img\logo.png
and without it, just via specifying: logo.png
Specifying the full path is recommended if you have several images with similar filenames.
If you have several files logo.png in your project, and you load it via specifying only file name "logo.png" then the first found image from your project will be loaded.
Resume: transfer your img folder into the src folder.

Not sure if this is the same as your problem, but when I get those types of errors, it usually means that I need to force the project in Eclipse to refresh (right-click on project and choose Refresh) and then rebuild.

Related

IntelliJ IDEA: Jar doesn't load images when run outside of IDE

I am using JetBrains IntelliJ IDEA IDE. This is what I used to generate the jar file. Running the jar file from the IDE, everything looks fine.
Running the jar from the terminal, none of the images are loaded.
My feeling is, from reading around on this, that this has something to do with the relative paths used for the images... but I can't figure this out. I've tried various different project folder structures suggested on the JetBrains forums and StackOverflow, to no avail. Everything is fine until I run a jar outside of the IDE.
My current project structure:
How on Earth do I create a jar file that works everywhere?
Ok, so here's what worked for me. I opened the project structure window (Ctrl-Alt-Shift + S) and went to the Modules tab. From there, I could easily select a folder from the list and click to make it a Resource directory. I was then able to access the resources as URL's with
URL imageUrl = ClassLoader.getSystemResource("image.png")
No need to use a path to the image, just it's actual name.ext
Using IntelliJ's resource folders is probably the right way to go.
Simply right click your res folder, go to Mark Directory As and select Resources.
Then you can access files in this folder simply by name (without a res/ prefix.)
Working visual example:
Source and Resource roots are handled differently.
All the files from the Resource directories will be always copied to the output path. As suggested in another answer, one of the solutions is to configure this directory as Resources root. It's the preferred way to get it working.
If you want files from the Source roots to be copied to the output, you have to specify the patterns for the files that will be copied.
If the project is Maven or Gradle based, these patterns have no effect and IDE will use the rules of the corresponding build system to process the resources.

Main class not found, IntelliJ building a jar

I am running into problems when I try to run the jar file created in IntelliJ.
I followed the steps laid out here: How to build jars from IntelliJ properly? and searched far and wide for other people with the same problem using IntelliJ, and found no solution.
In the menu Project Structure>Artifacts section I have the package and main class name, and I have also tried specifying the 'Class path' bit using a relative and absolute path both to the source file and the .class file (which seems hidden in the IntelliJ Project display tree..), but even with all this (I also make sure to rebuild the jar every time I change something) I get the "Cannot find the main class. Program will exit." message when I try to run the jar.
In the main project folder, there is src and out.
out contains 'production' with the package tree and the class files
out also contains 'artifacts' with the jar folder and jar executable
src contains a folder of images, the META-INF and the package tree.
the first folder in the package contains the main class, so src/ravelDemo/RavelDemoMain.java
in Project Settings>Artifacts, the main class is listed as ravelDemo.RavelDemoMain
currently, the class path is out\production\RavelSequence v1.03\ravelDemo\ but this and every other class path I've specified (or left blank) doesn't seem to point to the right place. (RavelSequence v1.03 is the name of the project).
What am I doing wrong?
Basing on the discussion is the comments above it appears that IntelliJ IDEA is building the valid executable jar with the main class correctly specified in the Manifest, this jar works fine when executed with java -jar ... command from the command line using the project target JDK version on the user's machine.
The problem is that it doesn't work on double click on #sideways8 system. It may be caused by the corrupted default Java installation or wrong .jar file type association in Windows registry. This is machine specific issue as I have no problem running the shared project jar on my system by double clicking on it.
To fix this problem you can try to uninstall all the Java versions present on this machine from the Control Panel | Programs and Features, then install new JDK from scratch so that it's the only JDK on the system and .jar file type is handled by it.
I use Total Commander which has a nice feature to check/edit file associations (File | Associate With...), here is how the .jar association is displayed when I press Edit type...:
I had the same problem. Either the jar file was created with IntelliJ IDEA or other IDE. I found out the problem in my case that I had two version of java installed on my computer (java 6 & java 8).
It's a problem of misconfiguration of the system. so remove any version of java you have and install it again and the problem is solved.

giving 'java.library.path' in netbeans for .dll/.so files

How do i give the path for the .dll or .so file in netbeans to load the library using
System.loadLibrary("Foo")
I read this on netbeans page but couldn't help me. as it gives the unsatisfied link error.
These are the two things i tried :
In the following snapshot i created a lib folder inside the netbeans project and placed the dll files inside it.
In the second snapshot i created a lib folder inside the modules folder and placed all the dll files inside lib folder as stated in the link.
But both of them give me unsatisfied link error exception. How do i set java.library.path in netbeans so that i can directly test the application from netbeans,
without having to go and write on the terminal ?
Its working now. Some little bit setting you have to do with your Netbean IDE.Only of Netbean IDE.
Follow the Steps :-
==>Right click on the Project
==>Properties
==>Click on RUN
==>VM Options : -Djava.library.path="C:\Your Directory where Dll is present"
==>Ok
Its working 100%. I have done this in my own project.
I'm using Mac OS X Yosemite and Netbeans 8.02, I got the same error and the simple solution I have found is like above, this is useful when you need to include native library in the project. So do the next for Netbeans:
1.- Right click on the Project
2.- Properties
3.- Click on RUN
4.- VM Options: java -Djava.library.path="your_path"
5.- for example in my case: java -Djava.library.path=</Users/Lexynux/NetBeansProjects/NAO/libs>
6.- Ok
I hope it could be useful for someone.
The link where I found the solution is here:
java.library.path – What is it and how to use
To me JDeveloper's suggestion didn't work. However, the method that I came across this early afternoon works handy.
It is for netbeans 8.02, and Visual Studio 2013 generated dll.
create a package(eg, "dll") under [Source Packages] node of netbeans
project
put/copy a dll file(eg, simpleDLL.dll) into the package(eg,
"dll")
on the [Libraries] node of the netbeans project, right-click
and choose "Add Jar/Folder...",
navigate to the folder("src") that contains the folder("dll") for the package that you created in step 1 above (it could be "...\src\dll" in my example), select package folder("dll") and click [Open] button to select it.
-- now you should have added a folder("dll") (which contains the dll file{simpleDLL.dll}) to the Libraries node of the project.
That's it. It should work!
Good luck.
IF you are working on "NetBeans Modules"
DLLs or SOs can be placed in the folder release/modules/lib/ in a module project's sources (look in the Files tab). This will make them appear in the final NBM or application in a lib subdirectory beneath where the module's JAR resides. Then just use System.loadLibrary as usual.

Distributable JAR not working

I created a project in Netbeans 7.1 on my netbook which uses Windows XP. I used the Clean and Build command which created the distributable JAR file in the /dist folder. When I double clicked the file it worked.
Now I sent the entire project folder to my desktop, which uses Windows 7 Ultimate 64 bit. When I double clicked the executable JAR I got an error saying:
Could Not find or load main class myapp.jar
I checked the manifest file and it contains the main class name. Of course, it was autogenerated by Netbeans.
What is going on?
The common mistake is to forget to also take the "layout" folder. If you have used specific features of Netbeans, such as bindings, in the "dist" you have the jar but also a folder with the name "layout" in it and you must also copy it with the jar file and put it at the same target place.
In my case it was a pity having to also send this folder so I decided to stop using binding and other specific stuff and used to reprogram things by hand. Now I only send the jar and it is working.
Note that you can easily know if you have specific features.
Open Netbeans and look in your project folder. There you'll have 2 folder, "Source Packages" and "libraries". Check in libraries. If you have only the JDK it is ok. If you have other libraries listed, then there will be the supplementary folder in the dist and you will have to send it with the Jar.
Hope it helps

Serve Modules without publishing not working in Helios

I have recently moved a webapp I have been developing to a new machine running 64bit Eclipse Helios (Service Release 2) and I am using Maven plugin M2Eclipse.
I have deployed on a local tomcat install through Eclipse and everything is ok (more or less), but I want to select the option "Serve Modules without publishing", but when I select this option I get errors:
log4j:ERROR Could not read configuration file from URL [file:/C:/butterfly/svn/trunk/micro/src/main/webapp/WEB-INF/classes/log4j.properties].
java.io.FileNotFoundException: C:\butterfly\svn\trunk\micro\src\main\webapp\WEB-INF\classes\log4j.properties (The system cannot find the file specified)
The log4j.properties file is not there, as in my source directories in lives in src/main/resources - at build it then gets copied over to target/WEB-INF/classes/..
Eclipse seems to be mixing the expected target directory with the src directory so not finding it.
Im not sure if this is happening for just the properties file or if the same problem will occur looking for all built resources.
I have seen these issues:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318449
http://www.eclipse.org/forums/index.php?t=msg&goto=661045&S=25bafd85b11e042c169ecf1752bfa479
but they seem to be slightly different or already fixed (My Helios is a new download from last weekend)
Anyone experience this or know how to resolve?
From here: "The Serve modules without publishing option does what it says. Web content will be served directly from the "WebContent" folder of the Dynamic Web Project. A customized context is used to make the project's dependencies available in the Web application's classloader". I would expect eclipse to emulate serving every class / resource file (including log4j.properties) from WEB-INF/classes after you build the project. As a workaround, what about creating a "classes" folder inside WebContent, copy log4j.properties file here and see if the classloader gets happy?

Categories

Resources