I am writing a Java program on a Windows PC, that needs to communicate with several applications on our company's Unix machines.
The program I developed contains a Swing interface with a JButton. For the moment, when I click on the button, I can select a directory like "C:\Users\MyUserName\Documents" on my machine. Here is the code sample :
selectButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// Choose a directory
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("choosertitle");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
} else {
System.out.println("No Selection ");
}
}
});
Now I would like to select a directory in another machine working with Unix (let's say the machine name is "unix-service") instead of a directory on my local machine. So when I click on the button :
I need to know the group of the user in our company to continue. In a Unix terminal, we can do it with the command "echo $WORK_GROUP". I want to save this user's group as a variable "user_group"
I want to select a directory "workgroug/user_group/username/" on that Unix machine.
How can I do it using ssh commands and adapting my code ?
I hope everything is clear and explained, do not hesitate to ask me if you need more information. Thank you for your time.