'Execute Java script via cmd from R

I use Windows and want to execute a Java script. However, the Java script is on drive D:, not C:. With the command

start /D "D:\\project\\Trimmomatic" java -jar trimmomatic.jar PE -phred64 -threads 16 x1.fastq x2.fastq clipped_paired_x1.fastq clipped_unpaired_x2.fastq clipped_paired_x2.fastq clipped_unpaired_x1.fastq LEADING:3 TRAILING:3

I can run trimmomatic.jar from C: in the prompt. However, if I wrap that line in R's system() command, and execute

system('start /D "D:\\project\\Trimmomatic" java -jar trimmomatic.jar PE -phred64 -threads 16 x1.fastq x2.fastq clipped_paired_x1.fastq clipped_unpaired_x2.fastq clipped_paired_x2.fastq clipped_unpaired_x1.fastq LEADING:3 TRAILING:3')

from R, it returns the bash error 127. Any ideas how to fix this or execute the jar file on D: in a different way?



Solution 1:[1]

@Where's my towel gave the answer. If you use shell() instead of system() it works!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anti