I am doing something about getting execution logs form a java program. But I just achieve this when it's a jar file using command like java -javaagent:agent1.jar -jar MyProgram.jar . But if there is a software which don't need using java -jar to open , how can I use my agent1.jar to get its execution data ? For example, I made a game by java ,and I open it by opening the file MyGame.exe ,which mean that I can't use javaagent:agent.jar to instrument and get logs.
Are there any ways to solve this problem or any other tools can give me a reference?
Related
Is it possible to run an entire, large, powershell script in a java application without calling it externally by launching a powershell process with the -file parameter? (passing it via the encodedcommand parameter won't work either because of the commandline lenght limitation).
I.e. is there a java library that enables you to paste your powershellscript inside your java app and run it?
I currently embed the powershellscript inside the java application and write it to disk, but I'm looking for a fileless approach.
Since you want to pass a large program, piping from the Java program to the PS script is more suitable than using the command line or environment variables. Since I don't know too much Java and don't have it installed, I'll simulate it from the PS command line in the snippet below. Your Java program would read the lines of the program from a list or some other suitable data structure (whereas this example reads it from the file system). I did see hits on google for piping from Java to an externally executed command.
cat my.ps1|
powershell -command {$scr="";foreach ($line in $input){$scr+=$line+"`n"} echo bxb $s cxc}
After your PS stub has received the program rather than echo it, it would execute it: iex $scr.
If you need to pass parameters from Java to PS you could either pipe them along with the program (for example as lines of code that set global variables) or they could be global variables set in stub code. Other, more complex, variations are possible.
I'm trying to automate creating torrents/starting downloads/limiting Bandwidth... etc using Vuze.
So far I've written a shell script to send Vuze and the torrent to all the clients. However when it comes to creating torrents, after executing this command : java -jar Azureus2-XXX.jar --ui=console or java -jar Azureus2-XXX.jar --ui=console &, the console looks like this and no command after that works unless I quit the Java program.
Any help would be much appreciated. Thanks!
I want to run bash file from java, i am using play framework.
any idea how to do that??
is this code enough:
new ProcessBuilder("pathToYourShellScript").start();
Possible duplicate of How to run Unix shell script from Java code? (don't have the reputation to put that in a comment, sorry).
In a nutshell - your line of code will work and the shell script will run by just doing that (tested on a SUSE Linux box).
However, if you want to do anything with the output or to know that it has completed, you'll have to add more code to check its state (check out the Process.waitFor() API) or to capture its output in Java (e.g. by capturing Standard out in a BufferedReader) - check Process.getInputStream() API.
I'm trying to output some debug info in a Sikuli script using print but I can see this info only after the script has finished execution because the IDE hides itself while the script is running. Is there a way to see those logs during execution? Like outputting this info to console or (better) not hiding IDE during execution?
(1) You could use a pop-up:
popup("Hello World")
(2) You can use Jython's File IO
f = open("myLogfile.txt", 'a')
f.write("Log Message")
f.close()
Now if you open the log file in a text editor that warns about changes made to the file (ie NOT Notepad.exe), you can then see your print statements every time the file is appended by your script.
You cannot hide the IDE in background during script execution.
However,there's an alternative to view the logs.
You can install the package which launches your sikuli via command prompt(sikuli-script.jar),
refer to https://launchpad.net/raiman/+download
you won't need the IDE to launch your scripts this way.
Now after changing necessary environment settings you can type-in simple path like "java -jar %Sikuli_Home%\sikuli-script.jar -r %Sikuli_Scripts%\main.sikuli" in cmd and get started.
here 'main' is my driver script where I have imported my modules under single .sikuli folder (main.sikuli) you can have any file name like abc.sikuli
(here you need to store your path in a variable like ,path = os.environ['Sikuli_Scripts'])
Also ,it is a good practice to launch applications creating batch files and accessing files using relative path.
I wrote a program to make a graphical Timeline and it works through some VBA and Java through the shell, but after transfering it over to Windows 7 from Vista I cannot seem to find a place to save the files so that the java program can access them. Please Help me. Where can I save the files such that I can have the java program access them and not throw an exception and blow up the program?
Update Now whenever I try to shell the java program I get a file not found exception runtime error 53 and it's on the shell call
Error that appears after calling java out of batch out of vba out of excel
Some reason it won't let me do this.
If you're targetting Windows Vista/7, you can build an EXE from a JAR file that has a certain manifest in it that makes the EXE require admin rights. This way, file I/O will always execute with the correct userrrights!