Josh Josh - 4 months ago 12
Java Question

Input values to a normal JAVA SE program

I'm new to JAVA and I'm currently trying out both Netbeans and Eclipse.

I'm confused about inputting values to my JAVA application.I see the output getting displayed on the output window in Eclipse ...but,I don't know how to input values ...??

In a normal console application in .Net,we can input values through the console window (Command Prompt Window) ,but I don't see any command prompt window coming up when I run my JAVA program to Input values or Type Anything.How do I do this?



If I remember correctly, you can actually type in Eclipse's Java console and that will be sent through the standard input stream, (probably depending on the application's run configuration).

However the standard way of doing this is to pass a number of strings on the command line, which will appear as the elements of the String[] parameter to your application's main method.

Alternatively you can get input in via flat files, from a database, through sockets etc. though this is, as you might expect, a lot more complex and should certainly not be considered for a "Hello World" type application. Java web services, for example, do take their input via network sockets rather than via the command line as this latter would restrict them somewhat. ;-)