Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i get console output into an exterm/putty session

 
felix culpas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have cobbled together the following java program "Shell2" it runs fine and outputs interactively to the Eclipse Console.... how do i get it to output to a xterm/putty session instead?

regards .. Java Newbie :-)




 
L Foster
Ranch Hand
Posts: 185
10
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Felix.  As a newbie, you have come to the right forum.  I hope I can answer your question.  Sorry if you have seen most of this before, and sorry if I made a wrong assumption.

It sounds like you would like to run your code outside of the Eclipse IDE, and hence see the output from the command line.  For that, you need to know these concepts:
* Compiling code.
* The java command line
* The java classpath.

First, let's assume you know your way around you OS' command line.  That means you know how to open a Putty session, and how to run commands like "dir" or "ls", "cd", etc.  Next thing, is compiling the code. An IDE does this for you, and you may not have had to know the mechanics of that up to now, to get the program working.  So, I will try and get you going there.

You need to know where your source code is stored, once you are at the command line prompt.  Many IDEs (I have not used Eclipse in a while) can tell you with a mouse-over or such, where the code lives.  So, you would "cd LOCATION" (whatever the location you found).  Since you are not using a package statement, your code is in the default package.  That means you can do your java-compile command (javac) right in the same directory, and still be able to find everything.  And finally, the "classpath" concept: this tells where all your dependencies are.  You are using only Swing code, which is builtin to Java's own jar files, so you can run your javac without adding any parameters for that.  It will by default include the current working directory.

One more thing: you have to have a "JDK" installed, and have it in your executable PATH (that's %PATH% in windows, or $PATH in linux/unix/mac osx).  You need a JDK instead of a JRE (which might be installed by default).  Possibly you have already dealt with this, since you did setup your Eclipse, but maybe not.

Now that the concepts have been briefly explained, I think these commands will do the trick.


"javac" compiles your code, to make another file called "Shell2.class", which should be in the current directory.  Then "java" runs the ".class" file, but you do not specify the extension.

I hope this helps.  Good luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic