Can I link a plain file into my executable? [duplicate]

You could do this: objcopy –input binary \ –output elf32-i386 \ –binary-architecture i386 my_file.xml myfile.o This produces an object file that you can link into your executable. This file will contain these symbols that you’ll have to declare in your C code to be able to use them 00000550 D _binary_my_file_xml_end 00000550 A _binary_my_file_xml_size 00000000 … Read more

Embed resources (eg, shader code; images) into executable/library with CMake

As an alternative to the answer of sfstewman, here’s a small cmake (2.8) function to convert all files in a specific folder to C data and write them in wished output file: # Creates C resources file from files in given directory function(create_resources dir output) # Create empty output file file(WRITE ${output} “”) # Collect … Read more

Java Swing: Displaying images from within a Jar

To create an ImageIcon from an image file within the same jars your code is loaded: new javax.swing.ImageIcon(getClass().getResource(“myimage.jpeg”)) Class.getResource returns a URL of a resource (or null!). ImageIcon has a constructors that load from a URL. To construct a URL for a resource in a jar not on your “classpath”, see the documentation for java.net.JarURLConnection.

How do I add an image to a JButton

I think that your problem is in the location of the image. You shall place it in your source, and then use it like this: JButton button = new JButton(); try { Image img = ImageIO.read(getClass().getResource(“resources/water.bmp”)); button.setIcon(new ImageIcon(img)); } catch (Exception ex) { System.out.println(ex); } In this example, it is assumed that image is in … Read more

How can I extract a file from an embedded resource and save it to disk?

I’d suggest doing it easier. I assume that the resource exists and the file is writable (this might be an issue if we’re speaking about system directories). public void WriteResourceToFile(string resourceName, string fileName) { using(var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { using(var file = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { resource.CopyTo(file); } } }

Loading resources like images while running project distributed as JAR archive

First of all, change this line : image = ImageIO.read(getClass().getClassLoader().getResource(“resources/icon.gif”)); to this : image = ImageIO.read(getClass().getResource(“/resources/icon.gif”)); More info, on as to where lies the difference between the two approaches, can be found on this thread – Different ways of loading a Resource For Eclipse: How to add Images to your Resource Folder in the Project … Read more

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