Shipping Java code with data baked into the .jar

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-23T23:07:27Z Indexed on 2010/03/23 23:23 UTC
Read the original article Hit count: 412

Filed under:
|

I need to ship some Java code that has an associated set of data. It's a simulator for a device, and I want to be able to include all of the data used for the simulated records in the one .JAR file. In this case, each simulated record contains four fields (calling party, called party, start of call, call duration).

What's the best way to do that? I've gone down the path of generating the data as Java statements, but IntelliJ doesn't seem particularly happy dealing with a 100,000 line Java source file!

Is there a smarter way to do this?

In the C#/.NET world I'd create the data as a separate file, embed it in the assembly as a resource, and then use reflection to pull that out at runtime and access it. I'm unsure of what the appropriate analogy is in the Java world.

FWIW, Java 1.6, shipping for Solaris.

© Stack Overflow or respective owner

Related posts about java

Related posts about data