Find what directory the running process EXE is stored in
Tag : cpp , By : Murali Ravipudi
Date : March 29 2020, 07:55 AM
|
How to find the process id of a running Java process on Windows? And how to kill the process alone?
Date : March 29 2020, 07:55 AM
Does that help You can use the jps utility that is included in the JRE to find the process id of a Java process. The output will show you the name of the executable JAR file or the name of the main class. Then use the Windows task manager to terminate the process. If you want to do it on the command line, use TASKKILL /PID %PID%
|
How do I find/list a file or directory with specific name inside a directory and its subdirectories in Java?
Tag : java , By : Chris Tattum
Date : March 29 2020, 07:55 AM
hop of those help? You can achieve the same using Java 7 Files.walkFileTree, PathMatcher and FileVisitor like this import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
public class MyVisitor extends SimpleFileVisitor<Path> {
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:data");
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
if (matcher.matches(dir.getFileName())) {
System.out.println("dir found " + dir);
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (matcher.matches(file.getFileName())) {
System.out.println("file found " + file);
}
return FileVisitResult.CONTINUE;
}
public static void main(String[] args) throws IOException {
Files.walkFileTree(Paths.get("full/path/to/your/search"), new MyVisitor());
}
}
|
How to find the process id of a process running on a port number in java
Date : March 29 2020, 07:55 AM
wish of those help I am new to java and window as well I want to kill the process which is running on a specific port. let's say 9090. , This is What you want to do . I hope it will help you. try{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd /c netstat -ano | findstr 9090");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
String s = null;
if ((s = stdInput.readLine()) != null) {
int index=s.lastIndexOf(" ");
String sc=s.substring(index, s.length());
rt.exec("cmd /c Taskkill /PID" +sc+" /T /F");
}
JOptionPane.showMessageDialog(null, "Server Stopped");
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Something Went wrong with server");
}
|
How to find which process removing a directory in linux?
Tag : linux , By : user182548
Date : March 29 2020, 07:55 AM
|