Questions tagged [console-application]

A console application is a computer program designed to be used via a text-only computer interface, such as a text terminal, the command line interface of some operating systems (Unix, DOS, etc.) or the text-based interface included with most Graphical User Interface (GUI) operating systems, such as the Win32 console in Microsoft Windows, the Terminal in Mac OS X, and xterm in Unix.

A console application is a computer program designed to be used via a text-only computer interface, such as a text terminal, the command line interface of some operating systems (Unix, DOS, etc.) or the text-based interface included with most Graphical User Interface (GUI) operating systems, such as the Win32 console in Microsoft Windows, the Terminal in Mac OS X, and xterm in Unix. A user typically interacts with a console application using only a keyboard and display screen, as opposed to GUI applications, which normally require the use of a mouse or other pointing device. Many console applications such as command line interpreters are command line tools, but numerous text-based user interface (TUI) programs also exist.

As the speed and ease-of-use of GUI applications have improved over time, the use of console applications has greatly diminished, but not disappeared. Some users simply prefer console based applications, while some organizations still rely on existing console applications to handle key data processing tasks.

7241 questions
64
votes
4 answers

Console application with Java and gradle

I am writing a console application with Java and gradle. I am using the application plugin and have the required fields correctly configured in build.gradle. In my main class I have BufferedReader linked with System.in. Here's the problem: When I…
missingfaktor
  • 90,905
  • 62
  • 285
  • 365
63
votes
11 answers

CPU friendly infinite loop

Writing an infinite loop is simple: while(true){ //add whatever break condition here } But this will trash the CPU performance. This execution thread will take as much as possible from CPU's power. What is the best way to lower the impact on…
Adi
  • 5,113
  • 6
  • 46
  • 59
63
votes
8 answers

Is there a way to delete a character that has just been written using Console.WriteLine?

Is there any way to delete the last character from the console, i.e. Console.WriteLine("List: apple,pear,"); // Somehow delete the last ',' character from the console. Console.WriteLine("."); // Now the console contains "List: apple,pear." Sure, I…
Contango
  • 76,540
  • 58
  • 260
  • 305
58
votes
4 answers

The non-generic method 'IServiceProvider.GetService(Type)' cannot be used with type arguments

I am using .NET Core dependency injection, but when I am trying to get the service in another class, I am getting the 'IServiceProvider.GetService(Type)' cannot be used with type arguments' error. What does this error means? I understand that a…
57913
  • 783
  • 1
  • 6
  • 13
58
votes
2 answers

Java: Updating text in the command-line without a new line

I'd like to add a progress indicator to a command-line Java program. For example, if I'm using wget, it shows: 71% [===========================> ] 358,756,352 51.2M/s eta 3s Is it possible to have a progress indicator that updates…
Tom Marthenal
  • 3,066
  • 3
  • 32
  • 47
55
votes
7 answers

How can I read the appsettings.json in a .NET 6 console application?

I try to create a .NET 6 Console Application but having troubles reading my appsettings.json file. In a web application I could use this... var builder = WebApplication.CreateBuilder(args); But what would I use in a console application? I get this…
MTplus
  • 2,077
  • 4
  • 34
  • 51
55
votes
2 answers

How to run .NET Core Console app using generic host builder

I am trying to figure out how to use hostbuilder pattern to run a console app (not a windows service). Intent is to keep the flow as similar to a WebApi to keep development practices similar. I have seen samples for using HostedService or…
askids
  • 1,406
  • 1
  • 15
  • 32
52
votes
5 answers

Masking password input from the console : Java

How to mask a password from console input? I'm using Java 6. I've tried using console.readPassword(), but it wouldn't work. A full example might help me actually. Here's my code: import java.io.BufferedReader; import java.io.Console; import…
New Start
  • 1,401
  • 5
  • 21
  • 29
51
votes
3 answers

How can I write fast colored output to Console?

I want to learn if there is another (faster) way to output text to the console application window using C# .net than with the simple Write, BackgroundColor and ForegroundColor methods and properties? I learned that each cell has a background color…
Statement
  • 3,888
  • 3
  • 36
  • 45
51
votes
10 answers

What is the difference between public static void Main() and private static void Main() in a C# console application?

What is the difference between public static void Main() and private static void Main() in a C# console application? Specifically as it pertains to the Main() method (I understand the differences between public and private).
jai
  • 582
  • 1
  • 6
  • 20
51
votes
14 answers

How to keep console window open

When I run my program, the console window seems to run and close. How to keep it open so I can see the results? class Program { public class StringAddString { public virtual void AddString() …
user1929393
  • 4,089
  • 7
  • 30
  • 48
51
votes
2 answers

Use custom console for Visual Studio Console Application Debugging

Is it possible to set Visual Studio to use a non-standard console when debugging a Console Application? I'm not sure what the default console is, it looks just like cmd.exe. I would really love my Console Application to run in ConEmu when I…
47
votes
1 answer

How does a Spring Boot console based application work?

If I am developing a rather simple Spring Boot console-based application, I am unsure about the placement of the main execution code. Should I place it in the public static void main(String[] args) method, or have the main application class…
Web User
  • 7,438
  • 14
  • 64
  • 92
43
votes
1 answer

How is a Scoped service instance handled in a .NET Core Console application?

I copied this from ConfigureServices in a web application I'm building, where I'm trying to move away from the web and only use a console app or service: serviceCollection.AddScoped(c => new…
ProfK
  • 49,207
  • 121
  • 399
  • 775
42
votes
7 answers

When should one use Environment.Exit to terminate a console application?

I'm maintaining a number of console applications at work and one thing I've been noticing in a number of them is that they call Environment.Exit(0). A sample program would look like this: public class Program { public static void Main(string[]…
mezoid
  • 28,090
  • 37
  • 107
  • 148