Load properties file in JAR?

The problem is that you are using getSystemResourceAsStream. Use simply getResourceAsStream. System resources load from the system classloader, which is almost certainly not the class loader that your jar is loaded into when run as a webapp. It works in Eclipse because when launching an application, the system classloader is configured with your jar as … Read more

Android Resource IDs

According to the documentation, Resources.getIdentifier() Returns 0 if no such resource was found. (0 is not a valid resource ID.) UPDATE (after 5+ years thanks to Micer): API 29+: Resources.ID_NULL constant older API: ResourcesCompat.ID_NULL

Ruby on rails: singular resource and form_for

Unfortunately, this is a bug. You’ll have to set the url like you mention. = form_for @order, :url => order_path do |f| Note that this will properly route to create or update depending on whether @order is persisted. Update There’s another option now. You can add this to your routes config: resolve(“Order”) { [:order] } … Read more

How can I access ResourceDictionary in wpf from C# code?

Since Application.Current was null in my case, I’ve ended up using this: var myResourceDictionary = new ResourceDictionary(); myResourceDictionary.Source = new Uri(“/DllName;component/Resources/MyResourceDictionary.xaml”, UriKind.RelativeOrAbsolute); and then getting the specified key I needed by using myResourceDictionary[“KeyName”] as TypeOfItem (source)

How can I detect which layout is selected by Android in my application?

You can set a different android:tag attribute on the views in each different resource file, and read the tag back at runtime with View.getTag(). Example: layout-xlarge-land/my_act.xml <View android:id=”@+id/mainview” android:tag=”xlarge-landscape” /> layout-xlarge/my_act.xml <View android:id=”@+id/mainview” android:tag=”xlarge-portrait” /> MyActivity.java String tag = view.getTag(); if (tag.equals(“xlarge-landscape”) { … }

How do I use an icon that is a resource in WPF?

Your icon file should be added to one of your project assemblies and its Build Action should be set to Resource. After adding a reference to the assembly, you can create a NotifyIcon like this: System.Windows.Forms.NotifyIcon icon = new System.Windows.Forms.NotifyIcon(); Stream iconStream = Application.GetResourceStream( new Uri( “pack://application:,,,/YourReferencedAssembly;component/YourPossibleSubFolder/YourResourceFile.ico” )).Stream; icon.Icon = new System.Drawing.Icon( iconStream );

Spring Boot access static resources missing scr/main/resources

Just use Spring type ClassPathResource. File file = new ClassPathResource(“countries.xml”).getFile(); As long as this file is somewhere on classpath Spring will find it. This can be src/main/resources during development and testing. In production, it can be current running directory. EDIT: This approach doesn’t work if file is in fat JAR. In such case you need … Read more

How to get a test resource file?

Probably just useful if you have the file available, for example when doing unit tests – this will not load it out of a jar AFAIK. URL url = Thread.currentThread().getContextClassLoader().getResource(“mypackage/YourFile.csv”); File file = new File(url.getPath()); // where the file is in the classpath eg. <project>/src/test/resources/mypackage/YourFile.csv

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)