Skip to content

Instantly share code, notes, and snippets.

@7shi
Created September 19, 2012 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/3749659 to your computer and use it in GitHub Desktop.
Save 7shi/3749659 to your computer and use it in GitHub Desktop.
JARにリソースを持たせる例
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.ImageIcon;
class ButtonTest extends JFrame {
public static void main(String[] args) {
new ButtonTest().setVisible(true);
}
ButtonTest() {
setSize(200, 100);
setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon icon = new ImageIcon(
getClass().getResource("onebit_11.png"));
JButton button = new JButton("Save", icon);
getContentPane().add(button);
}
}
TARGET = ButtonTest.jar
$(TARGET): ButtonTest.class onebit_11.png
jar 0cvfe $@ ButtonTest $^
ButtonTest.class: ButtonTest.java
javac $<
clean:
rm -f $(TARGET) *.class
# onebit_11.png is in the public domain.
# http://www.icojam.com/blog/?p=177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment