Hi all,
I access YUICompressor java file with jShell, this library minify JS and CSS files by removing whitespaces, tabs,
end of lines and any character that not really needed and so to be smaller when load in the webpage.
I had 2 chances, or use the java library and manage it with java, or access directly the jarfile with a shell and manage it directly on B4J. I opted the second solution.
All commands worked when I just have to save files, but I cannot get to work the command where I inject the (js or css) code string
to stdIn and get back the minified string from stdOut.
The string only is returned back when I close the app, and here I can see it printed to the log, and received in stdOut event.
I tried even to manually kill the process with shell.KillProcess, but this way the string do not return back because the process is killed.
I tried experimenting directly with jar file and Windows command prompt, and this is how they works.
Omitting the -o OutputFile.js but placing in the command just a source eg. InputFile.js, it read source file and return a minified string on stdOut
Omitting both -o OutputFile.js and InputFile.js, it expects an input from stdIn and output the minified string to stdOut. (here we only have to specify a file type, see below)
Here I want to use a second option, so pass the string and get the resulting minified string.
On Windows command prompt, here is what happen:
To get a resulting string, just press the first button, here you do not see nothing in the log, at this point close the app with top-right X.
After that you will see that stdOut event is raised and the log show a resulting string.
Probably I have to send an EOF before killing the process, but I do not know how I can do it, may using Robot library ? Or just using shell.WriteToInputStream ?
I attached the small project to reproduce it, here I just pass a code string to the compressor and try to get back the resulting minified string.
In the project the yuicompressor-2.4.8.jar file is placed in DirAssets and copied to DirTemp where it is executed. This is a small file (800kb), but because upload limit, if you want to help and reproduce it you have to download it from here and place to DirAssets. https://github.com/yui/yuicompressor/releases
Please can someone help me to get it working ?
Many thanks
I access YUICompressor java file with jShell, this library minify JS and CSS files by removing whitespaces, tabs,
end of lines and any character that not really needed and so to be smaller when load in the webpage.
I had 2 chances, or use the java library and manage it with java, or access directly the jarfile with a shell and manage it directly on B4J. I opted the second solution.
All commands worked when I just have to save files, but I cannot get to work the command where I inject the (js or css) code string
to stdIn and get back the minified string from stdOut.
The string only is returned back when I close the app, and here I can see it printed to the log, and received in stdOut event.
I tried even to manually kill the process with shell.KillProcess, but this way the string do not return back because the process is killed.
I tried experimenting directly with jar file and Windows command prompt, and this is how they works.
Omitting the -o OutputFile.js but placing in the command just a source eg. InputFile.js, it read source file and return a minified string on stdOut
Omitting both -o OutputFile.js and InputFile.js, it expects an input from stdIn and output the minified string to stdOut. (here we only have to specify a file type, see below)
Here I want to use a second option, so pass the string and get the resulting minified string.
On Windows command prompt, here is what happen:
- Send the command java -jar yuicompressor-2.4.8 --type js (--type js or --type css should be used so the compressor know what type of file have to manage)
- At this point the compressor open the stdIn pipe and undefinitely wait for input
- This happen until a RETURN and EOF character are received in sequence. From my search on the web I see that EOF is CTRL+Z on Windows and CTRL+D on Unix machines
- After that seem the process have to be killed. Here on Windows CTRL+C stop the process, but even dismiss the current input. I found that CTRL-BREAK do some tricks, in the prompt it return some log errors because the current thread stopped, but at the end, before return to the command prompt, it show the minified string that was processed.
To get a resulting string, just press the first button, here you do not see nothing in the log, at this point close the app with top-right X.
After that you will see that stdOut event is raised and the log show a resulting string.
Probably I have to send an EOF before killing the process, but I do not know how I can do it, may using Robot library ? Or just using shell.WriteToInputStream ?
I attached the small project to reproduce it, here I just pass a code string to the compressor and try to get back the resulting minified string.
In the project the yuicompressor-2.4.8.jar file is placed in DirAssets and copied to DirTemp where it is executed. This is a small file (800kb), but because upload limit, if you want to help and reproduce it you have to download it from here and place to DirAssets. https://github.com/yui/yuicompressor/releases
Please can someone help me to get it working ?
Many thanks
Attachments
Last edited: