1. There are two problems with using the basis to identify the nonzero variables. First, variables with finite upper bounds (or nonzero lower bounds) may be nonbasic but nonzero. Second, CPLEX has the basis for the problem after preprocessing. Not all the original variables survive preprocessing, and I would not be shocked if some variables in the model CPLEX is actually solving are inear combinations of original variables. So CPLEX will have to reverse the preprocessing transformations to find which of your variables are nonzero.
2. Yes, some of the low-level access stuff is available only through the C API. Even C++ users are out of luck.
3. For one thing, there's some overhead in setting up function calls and processing their results. You pay that "fixed cost" each time when you iterate over individual variables.
If you are using Java 8, you may be able to speed things up a bit using streams. Use an IntStream of indices, filter it by keeping indices of nonzero entries (remember to allow for some rounding error -- treat x as zero if |x| < epsilon), collect the survivors in a List, then iterate over that list to match nonzero values to their variables. You should be able to use parallel streams to speed this up (if you have multiple cores/processors).
#CPLEXOptimizers#DecisionOptimization