• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Programming from the command line?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guten Tag everyone,

I was wondering if there was any way to program from the command line prompt. I am running windows 7, and I can compile and run code using the javac and java commands with the JDK, but I was wondering if I could program from the command line as well, instead of using an IDE or even NoteBook. Thanks in advance.
-Tim Hoyle
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

and welcome to JavaRanch

What exactly do you mean by "programming from the command line"? As Java isn't a scripting language and therefore doesn't provide something like a scripting shell you should at least have some kind of editor. Maybe the old command line editor (don't know if it's still included in Windows 7) is enough for you then you can program from the command line. More or less. It may work but it's surely not very convenient without any tool support.

Marco
 
Tim Hoyle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marco,

Thanks for the reply.

I know what you mean about tool support. It is a lot easier to write code with an editor. However, I have a buddy who is asking me to research the idea for him. I have always used netbeans to compile and run programs, personally.
I am simply researching the idea of writing code from the command prompt (yes, windows 7 still has it) and saving it in a .java file so that one can compile it with the javac command and run the .class file with the java command.

-Tim Hoyle
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Tim,Welcome To JavaRanch
Yes You can do that.But provided you provide the argument while running the code
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A more convenient approach would be to find a command line editor of your choice which can help you to automate at least the edit-compile-run-cycle a little bit to speed up development. On Linux for example Emacs or vi are well-known editors which at first seem to be simple command line editors but there are many ways to extend the core functionality which makes a little command line IDE of these editors. I guess they are ported to windows too (maybe via Cygwin) or probably there are other command line editors for Windows which allow similar features.

Marco
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Marco - using some sort of editor (even the "edit" command (assuming it still exists in Windows 7)) would be better than straight command line. However it is possible:

Verify that it was stored correctly:

Compile and run it:
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, this is hardcore But in this case you should at least eliminate line breaks altogether and reduce the source file creation with "echo" to a single echo command
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andrew Monkhouse wrote:... even the "edit" command (assuming it still exists in Windows 7)) ...


In case you are unaware of that editor, it was introduced around DOS 4.0 (I think - I remember using it prior to Windows 3.1). From the command line, you enter "edit [filename]" (e.g. "edit Hello.java") and it opens the file in a simple editor:



Not a great editor, but it will get the job done. And is way better than millions of "echo" type statements.
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marco Ehrentreich wrote:OK, this is hardcore But in this case you should at least eliminate line breaks altogether and reduce the source file creation with "echo" to a single echo command


And reduce all class names and variable names to a single letter!
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

And reduce all class names and variable names to a single letter!


Absolutely! Just imagine all those wasted bytes!

Btw. your screenshot reminds of the times when we really used this editor to save a few bytes just by tweaking our AUTOEXEC.BAT or CONFIG.SYS file! Those were the days...
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marco Ehrentreich wrote:Btw. your screenshot reminds of the times when we really used this editor to save a few bytes just by tweaking our AUTOEXEC.BAT or CONFIG.SYS file! Those were the days...


Yep - I remember those days!

And writing batch scripts that would create separate batch scripts based on user inputs that would then be run to perform installations or upgrades of software.
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oooh - just thought of going even more hardcore!

Get Vim for PCs, and combine it with eclim to give you a command line Eclipse.
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Back then it was at least possible to know all the files on your harddisk and to understand what this machine was doing... most of the time

@Tim: It's not necessary to work without an IDE just because of these memories
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
copy con > ClassName.java

Then just ^Z to close the file.

Why... different issue.

I remember when my friend Tom got his Apple ][+ but we had no RF converter so we wrote BASIC/assembly that made sound without being able to see *anything*.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic