This can be achieved by following the steps below.
--Connect to Google colab and connect to Google drive
test1.py
#Mount google drive
from google.colab import drive
drive.mount('/content/drive')
--Processing until sample source execution
test2.py
#Set the current directory
import os
import shutil
os.chdir('/content/drive/My Drive/Java_sample')
path_name = os.getcwd()
#Upload the source and copy it to the specified folder
file_name = '/HelloWorld.java'
path_all = path_name + file_name
print(path_all)
shutil.copy(file_name, path_name)
#Compile and run Java source with commands
!javac HelloWorld.java
!java HelloWorld
--The two are separated for testing by a mechanism called a cell. (Implementation result)
Recommended Posts