0

I'm a noobie to Java and I had some questions, I think they may be easy (duh) answers to you experts but for me, I couldn't figure out the answer.

What is the point of Java programs, all I am making in my class now are simple read text files, have user input some stuff on the command line and the program prints out something. Like, it's cool and all that I can make a program do this but what does this all lead up to?

Say, I create a java program that converts celcius to fahrenheit and I want to have someone use it. Would I be able to get someone to use it that has no knowledge of Java, that is to say, giving it to my mom and she can run it from her computer without using Eclipse? How do I have someone who has no knowledge of coding run my program?

And my last question is, what is the point of command line arguments? Instead of putting them in the arguments, why not just have it in the code itself? Is it because if the code is big, it might be hard to find it? And if I download code that requires argument input, is it possible to download the code with the arguments set in Eclipse or would I have to manually do it?

Thanks, sorry for the long paragraph, but just wanted to put my thoughts down.

Jack Ryan
  • 7
  • 4
  • "Instead of putting them in the arguments, why not just have it in the code itself?" Um, so that they can change each time you run it... (Think about `javac` for example... without command line arguments, how would you tell it what to compile?) As for the uses of Java... think about Android apps, and web sites built in Java. End-user desktop apps written in Java are *relatively* rare, although they do exist (and no, you don't need Eclipse to run them). – Jon Skeet Nov 17 '14 at 19:55

3 Answers3

0

I think the short answer is modularity. Compiling or building a Java program takes time and knowledge (like you mentioned, someone who has no knowledge of Java probably wouldn't know what to do).

Passing in command line arguments allows you to just send someone the binary distribution of your program and passing in their own parameters without having to know what your code looks like or have to modify it.

In real life, programs aren't run from Eclipse (obviously), they're usually packaged into jars or wars and executed from the command line or some kind of app server.

If you download code that requires command line arguments, you will probably have to put them into Eclipse yourself, but hopefully the application has some documentation or help usage that explains what the arguments should look like.

mdnghtblue
  • 1,117
  • 8
  • 27
0

You can create your own jar files that you can run from the console.

One of the simpliest ways to make your program usable without using Eclipse is with the Windows command prompt or Linux terminal:

  1. go to you working directory (where your java file is stored)
  2. Type javac (Example:javac hello.java) -This would compile your program
  3. Type java (Example: java hello) - This will start it

Using of args is when you want to set some information to your program with the launching of the program.


Another way to start your program without using Eclipse is to make your own executable jar. With this you will get something like .exe file From which you can start your aplication


Most of the java programs are started from the CMD / terminal, or runs on java servers. There are aplication which have their own user interface (SWING, SWT, AWT ...) .


Most popular types of Java usage is creating a serious bussiness software, android aplications, complex web aplications etc.

Altair
  • 168
  • 1
  • 9
0

what is the point of command line arguments?

Benefits of using Command line.

if I download code that requires argument input, is it possible to download the code with the arguments set in Eclipse or would I have to manually do it?

Right Click on project-name > Run > Run Configuration > select Arguments tab

For more info click here.

What is the point of Java programs, all I am making in my class now are simple read text files, have user input some stuff on the command line and the program prints out something. Like, it's cool and all that I can make a program do this but what does this all lead up to?

This is just the begining. Learn Java core. Get familiarized with Java. One day you will be building tools using Java. eg:- Apache

How do I have someone who has no knowledge of coding run my program?

Compiling a java program into an executable

Before you do any this, get a book on Java (my fav - Java The Complete Reference) and read it. Learn how Java works, why is it different from other languages, best practices etc... After 2-3 years from now, you'll get the importance of taking a small step by building simple cmd line programs using Java

Community
  • 1
  • 1
Mitesh Pathak
  • 1,306
  • 10
  • 14