I have a java program and I want it to be able to print out its location on the computer. For example, if I were to place the program in the Downloads folder, and run it, it would print out the path to the file.
            Asked
            
        
        
            Active
            
        
            Viewed 125 times
        
    -1
            
            
        - 
                    1Does this answer your question? [Getting the Current Working Directory in Java](https://stackoverflow.com/questions/4871051/getting-the-current-working-directory-in-java) – wpnpeiris Mar 31 '20 at 07:26
1 Answers
1
            new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
.toURI()).getPath();
make sure to change the Myclass.class stuff
then system.out.println(File)
 
    
    
        Nikita
        
- 61
- 6
