n0va_sa

java compile and execute Python Script

Jan 29th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. #!/usr/bin/python3.5
  2. # in your case the python bin may be different!
  3. import os
  4. import sys
  5. def main():
  6.     retVal = os.system("javac " + sys.argv[1].split('.')[0]+'.java')
  7.     #if the javac is able to compile the code properly it wll return 0 else some other value!
  8.     if(retVal is 0):
  9.         print('[+] Compiled Successfully')
  10.         print('[+] Executing Java Application')
  11.         os.system("java " + sys.argv[1].split('.')[0])
  12.     else:
  13.         print('[-] Not Compiled Successfully')
  14.  
  15. if(len(sys.argv) < 2):
  16.     print("[-] need a .java file")
  17.     print(":~$ javaPy ConsoleAppDemo.java")
  18. else:
  19.     main()
Add Comment
Please, Sign In to add comment