I'm getting further and further to figuring out how my java program can read from my console application written in vb.net, i have some of my class here that i found on a site:

This is mainly to do with reading numbers from input but il change it later.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.text.ParseException;

public class InputHandler{
	public static void main(String[] args) {
	System.out.println("Reading from console.");
	double numberFromConsole; 
	try {
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String s = br.readLine();
	DecimalFormat df = new DecimalFormat();
	Number n = df.parse(s);
	numberFromConsole = n.doubleValue();
	} catch (IOException e) {		
                numberFromConsole = 0;
	} catch (ParseException e) {
		numberFromConsole = 0;
    		System.out.println(numberFromConsole );

This reads input from my console application but how do i call it from my main process so that the user can type away into the console and the java program picks up the input and then puts it into a string.

I know if this seems basic but I'm really not that good with java, I'm mainly used to programming in vb, vb.net and C#.

Recommended Answers

All 2 Replies

Compile it, I think if you are console the command is >javac InputHandler.java (if I remember correctly because for a very long time I have been using IDEs) and run it with the command
>java InputHandler
Then the program will print the message in your code and then just insert the input.

Thank you soooo much, i can now do input into my java program woohoo :) thanks allot! this is going to allow me to do so much more then i used to be able to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.