Another Java wish: it would be great to be able to query whether Stata has or could load a specified class.
I have the following scenario in mind. Let's say I write a Java helper class named Helper and add it to SSC. I then write a new class named MyClass that uses Helper, adding that to SSC. The MyClass package comes with the Stata wrapper program -myclass- so that the user doesn't have to interact with Java in any way.
I don't want to distribute Helper with MyClass, because I don't want to have to update the MyClass package every time I update Helper. Yet if the user downloads MyClass without Helper and tries to run -myclass-, a ClassNotFoundException will be thrown and the user will see a Java stack trace. An error is inevitable here, but I'd like to issue a error message more informative to a non-Java user, something like "SSC package helper required; to install, type ssc install helper". If MyClass could query from Stata whether Helper is loaded, I could do that. I could have MyClass display an error, then return to Stata with a nonzero return code before the exception is thrown.
I have the following scenario in mind. Let's say I write a Java helper class named Helper and add it to SSC. I then write a new class named MyClass that uses Helper, adding that to SSC. The MyClass package comes with the Stata wrapper program -myclass- so that the user doesn't have to interact with Java in any way.
I don't want to distribute Helper with MyClass, because I don't want to have to update the MyClass package every time I update Helper. Yet if the user downloads MyClass without Helper and tries to run -myclass-, a ClassNotFoundException will be thrown and the user will see a Java stack trace. An error is inevitable here, but I'd like to issue a error message more informative to a non-Java user, something like "SSC package helper required; to install, type ssc install helper". If MyClass could query from Stata whether Helper is loaded, I could do that. I could have MyClass display an error, then return to Stata with a nonzero return code before the exception is thrown.
Comment