467,092 Members | 1,263 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,092 developers. It's quick & easy.

Open a file in google chrome with cmd without swapping to the new tab

Nibble
I'm new here and I'm looking for help, I found this way to open files on google chrome with java:


private void abrirVideo(String archivo) {
File arch = new File(archivo);
String comando = "cmd.exe /c start chrome \"" + (archivo) + "\"";
try {
String s = arch.getParent();
Runtime.getRuntime().exec(comando, null, new File(s));
} catch (Exception ex) {
System.out.println("Error abriendo archivo: " + archivo + "\n" + ex);
}
}


and it does work fine, it opens the file in the same window, but the problem I have is that it automatically swaps chrome to the new tab, I've been looking for a couple days on the web and I don't see any post about this. Is there a way to open those files (like pictures, videos, etc...) in chrome in a new tab, without automatically swapping to that new tab. Thank you for your help.
3 Weeks Ago #1
  • viewed: 2562
Share:
3 Replies
dev7060
Expert 256MB
and it does work fine, it opens the file in the same window, but the problem I have is that it automatically swaps chrome to the new tab, I've been looking for a couple days on the web and I don't see any post about this. Is there a way to open those files (like pictures, videos, etc...) in chrome in a new tab, without automatically swapping to that new tab. Thank you for your help.
What does 'swap' signify here? Switching of the active tab?
3 Weeks Ago #2
Nibble
Yes. It switches the active tab to that new tab.
I couldn't find any way to do it so i had to use this chrome extension to force chrome to never switch to new tabs:
https://chrome.google.com/webstore/d...ajdbikelkdcmcl
But that solution could stop working in the future, so if you know any way to do it in the code itself i'll be really thankful.
6 Days Ago #3
dev7060
Expert 256MB
Command-line switches and flags may prove useful. Refer to the documentation.
6 Days Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.