I don’t know why you need to package them into rar files. You can instead embed them in your jar file itself. If you still need to, there is an opensource library called [icode]JUnRAR[/icode]
There is a limitation though, the rar files should be on the filesystem. A sample code would be
import com.github.junrar.*;
// Open an archive
Archive myRAR = new Archive(new File("myRAR.rar"));
// Get all the files
List<FileHeader> files = myRAR.getFileHeaders();
// The input stream of the file
InputStream ins;
// Iterate and get the file with your name
for (FileHeader hd : files)
{
if (hd.getFileNameW().equals("myfileinrar"))
{
ins = myRAR.getInputStream(hd);
break;
}
}
I didn’t try this but this is my assumption that this will work by seeing the source. Hope this works.