This question is different from "Find files in a folder using Java" that has already been asked because I do not know what the users current working directory will be. I need my program to look in the current working directory that the program is running from, to look for a certain file.
I need to have my program check to see if a file ending with ".lic" exist in the current working directory before it executes. If the file does not exist, I need a message to appear alerting the user that they need to activate the license. Here is the code that I have.
When I run it through the debug, "user.dir" give a message - user.dir = >Unknown type "user.dir"<
String License says "License = >"License" is not a known variable in the current context.<"
try{ String License = System.getProperty("user.dir") + ("*.lic"); File license = new File(License); if (license.exists()){ try{ Runtime.getRuntime().exec(cmd); } catch (IOException ex) { } } else { JOptionPane.showMessageDialog(null, "Need to activate license, please see README file"); } }catch(HeadlessException e){ // if any error occurs } }