c# open website in browser console code example
Example 1: how to open a webpage with java
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
String url_open ="HTTPS://www.google.com";
try {
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url_open));
} catch (IOException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
Example 2: use appsettings.json in console app
All that’s required is to add the following NuGet packages and an appsettings.json file.
Microsoft.Extensions.Configuration
Microsoft.Extensions.Configuration.FileExtensions
Microsoft.Extensions.Configuration.Json
The appsettings.json files “Copy to Output Directory” property should also be set to “Copy if newer” so that the application is able to access it when published.