I'm currently developing for Android using Eclipse. I have a lexicon viewer application (with package name "com.mycompany.myviewer") that I want to reuse multiple times, just changing specific resources such as app name and icons.
For example, I have a certain publisher "Publisher1", who publishes the lexicons "Lexicon1" and "Lexicon2". I would need to two applications: App1 with certain name and icon, and App2 with another name and icon.
What is the best way of doing this in Java? In visual Studio (and C++) I could create two projects based on the lexikon viewer app and use conditional resources to get the right name and icon. Is there some way of doing something similar in Java?
views:
102answers:
2
+1
A:
You can pack your lexicon viewer classes in its own .jar
archive to use as library in the actual projects. Next you can define the resources in a property file like lexicon_viewer.properties
that you allocate through a classloader using getResourceAsStream:
Properties props = new Properties();
String propFilename = "lexicon_viewer.properties";
InputStream is = PropertiesUtil.class.getClassLoader().getResourceAsStream(propFilename);
props.load(is);
In your project .jar
archives you include the lexicon properties file with the specific resource information like aplication name, icon filename, etc. The icon you can load via the same mechanism. For test purposes you can create a property file in the filesystem making sure it is early in the classpath.
rsp
2009-11-24 10:03:21
+1
A:
In Eclipse you can have multiple projects in the same workspace depend on each other.
- Import the core project and the dependant projects into the same workspace.
- Right click on a dependant project in the project explorer, select the menu item:
Build Path -> Configure Build Path
- This will bring up the
Java Build Path
dialog box, select theProjects
tab. - Click on the
Add
button to the core lexicon viewer application project as a dependency for App1. - Repeat the process for App2 and any other projects you want to depend on your core project.
Tendayi Mawushe
2009-11-24 10:18:20