• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you guys please explain me this

 
Richards Milan
Greenhorn
Posts: 29
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the "main" method ' public static void main(String[] args) ', why are we passing the String parameter args ?
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here you go

The main method accepts a single argument: an array of elements of type String.

public static void main(String[] args)

This array is the mechanism through which the runtime system passes information to your application. For example:

java MyApp arg1 arg2

Each string in the array is called a command-line argument.

 
Richards Milan
Greenhorn
Posts: 29
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Jelle ! it was really helpful
 
Richards Milan
Greenhorn
Posts: 29
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what exactly does " setting a classpath " mean ? why is it nescessary to set environment variables PATH , CLASSPATH in windows platform ??
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Setting a classpath" simply means setting the CLASSPATH environment variable.

Windows uses the PATH environment variable to find programs to execute. The PATH consists of a list of directories where Windows will look for *.exe files (executable programs). Normally, you'll want to add the bin directory of your JDK installation directory to the PATH, so that Windows can find the JDK tools when you're working in a command prompt window. See Updating the PATH Environment Variable in the JDK installation instructions.

The CLASSPATH is used by Java to find Java *.class files. Normally you'll want to leave the CLASSPATH environment variable not set.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12100
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FWIW - these are not unique to Windows. Unix/Linux uses the same environment variables. I don't know enough about the Mac OS, but i would be surprised if there wasn't something similar there.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richards Milan,
Your post was moved to a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic