I have installed cygwin on window to start crawling. It work well.
Now i want to run cygwin and run a crawl program at starting of cygwin using java program code.
If you provide some code for it ,it will be great help for me.
I looked at adatapost's link. It seems like a world of trouble awaits you down this path.
I mean, I like Cygwin a lot, but I wouldn't use it like this.
A few centimetres to the right of the 'Your Answer' box I'm typing in is a link to a Related question 'How can I run cygwin from Java?'
Who's putting the cart before the horse? I don't know.
Does Cygwin have to be involved at all ?
If you are trying to run a binary that requires the cygwin1.dll (which includes most commands you can execute from the cygwin bash shell) then you can run it by specifying the cygwin\bin directory in the path environment variable like this:
Process p = Runtime.getRuntime().exec("C:/path/to/cygwin/binary.exe", new String[] { "PATH=C:\\cygwin\\bin" });
This assumes you installed cygwin in C:\cygwin
Related
I wanted to put a java classfile up for download recently, which people could run in Terminal. It's a Minecraft command generator, so the people downloading it won't necessarily have the greatest mental capacity (I'm referring to 8-year-olds who have no idea what they're doing, of course).
Anyway, I wanted to provide a simple, single command, both for the Mac / Linux terminal and the Windows command line, that ran the classfile without any complications. The problem is, I don't want to execute it by doing /cd path, and then doing java someFolder.someClass. I just want to have a single command to open the file. If anyone could provide these commands for me, both in Mac / Linux and Windows, that would be great.
Sorry for the super long explanation :P
A jar file with a main class in the manifest would probably be the easiest thing. Then the command is java -jar myjarfile.jar.
A swing application would probably be easier as the default way of running executable jars doesn't open a command prompt (it uses javaw instead of java).
You will have to first start a terminal and then run java in that terminal, which can be a bit tricky.
How to open a command terminal in Linux?
Why not create an interface (Swing) and pack everything in a jar?
I have a .sh scripts in Linux.
I want to create a form in Java (eclipse) on Windows
and execute those .sh files.
Is there any simple way to do this?
At first you need to be able to run those shell scripts on target computer.
So try Cygwin, MinGW or other Unix emulators.
If run successfully next step is to use Runtime.getRuntime().exec(command) for running script. You have to set up environment (run another command before) to make it working.
The gcc compiler on CDT Eclipse for Windows is working this way.
.sh is a a shell script, most likely the default shell for a linux system, i.e. bash, so no, it won't run on your Windows machine. You can try Cygwin shell but still there is no guarantee that it will run. You will have to rewrite it for Windows batch script or your some other scripting language.
As far as Java is concerned, you can write in Linux and the code is portable to any other machine supporting JavaVM.
No there isn't. Perhaps intalling Cygwin would be an option, but I would not recommend to go that way.
Or perhaps I misunderstood. If you like running those scripts on your linux-machine, you can trigger a remote execution easily by using the appropriate java commmands or libraries (eg: jssh or anything like that).
I need to run a Java lib called FlowDroid in the Mac terminal.
I followed the documents and download the nighty build version of FlowDroid project.
After that, I use the commands that provided in the website but it does not work.
java -cp soot.jar;soot-infoflow.jar;soot-infoflow-android.jar;slf4j-api-1.7.5.jar; slf4j- simple-1.7.5.jar;axml-1.0.jar soot.jimple.infoflow.android.TestApps.Test "D:\Callbacks_Button1.apk" D:\Tools\AndroidSDK\sdk\platforms
I think it is a Java classpath problem, but I cannot figure it out. Whats wrong with the above commands?
As we don't have your exact error, that's pretty difficult to help. Anyway, on Mac OS X you should use the : as a classpath separator instead of ; which is for Windows systems.
Your command line should then look like:
java -cp soot.jar:soot-infoflow.jar:soot-infoflow-android.jar:slf4j-api-1.7.5.jar:slf4j-simple-1.7.5.jar:axml-1.0.jar soot.jimple.infoflow.android.TestApps.Test "D:\Callbacks_Button1.apk" D:\Tools\AndroidSDK\sdk\platforms
Hi I need to be able to check if a certain software is installed on the clients computer and where, in order to launch it. I found the following three posts as to how to do so on Windows and Mac but I can't seem to figure it out for Linux as there is no registry. Does any one know how this can be done on Linux?
Similar posts for Windows and Mac:
Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction?
read/write to Windows Registry using Java
How can I see the software installed in a Mac OS using a java application?
any help would be greatly appreciated :)
Assuming your security context allows it, you could call out to which.
$ which java
/usr/bin/java
which will output nothing if the program is not found.
Use the
which file
command to find out if the software is installed in the path. If that comes up with nothing then you could do a
find ./ -name "file"
Also check their local bin or .bin if its not included in the path.
Well, basically every binary installed on Linux is in the PATH (environment variable), so if you can find it there, it's there.
There may also be software that installs into other paths, but in this case the user would need to point them out. It is a very uncommon case to have an application in a seperate path and not adding that one to PATH.
I have a program that uses external libraries and code I've written in Java. However, I want to make it accessible via the web.
If I had full control over the webserver I was running it on, I would probably use Tomcat or JBoss, but I don't have such privileges at my school.
The servers I do have access to have Apache HTTP server with all the normal Linux goodies installed (think: Perl, PHP, etc.)
How would I write a Perl script that runs this Java program?
I've tried the basics such as "system java MyProgram" and "exec java MyProgram", but they don't seem to work.
I'd appreciate any help or insight on this. Thank you!
Process process;
try
{
process = Runtime.getRuntime().exec("cmd / c start c:\\Perl\\bin\\file.pl");
try to run like this as per your program.
When you run a CGI script, the environment is very limited, and this includes the PATH. Is it possible that your CGI script can't find the java command? Or maybe Perl simply is refusing to run the system command when in CGI mode (aka taint mode). See perldoc perlsec for more information.
Basically, you need to set PATH and then try running your system command with your java command.
Try this:
system('/full/path/to/java -cp full_class_path my.class.Name');