• 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

I want to compiling Java file using terminal

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want run java program using terminal and I want to save .class file in out directory and .java file in src directory so please any one give me command line instruction.
 
Saloon Keeper
Posts: 7601
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may help: https://coderanch.com/t/769388/java/NoClassDefFoundError-terminal

And more in-depth instructions are at https://coderanch.com/wiki/659740/create-Java-program
 
Ranch Hand
Posts: 68
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In CMD

javac <filename.Java>  // compiles the java file and generates byte code

whereas java <filename.java> directly runs the java program // I don't recommend this, it's better to first compile and then run

( assuming you are in the right file_path )
 
Marshal
Posts: 79471
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We don't use a file_path in ordinary Java® compiling. It is easiest to navigate to the folder where the XXX.java files are, but it is possible to change the CLASSPATH to gain access to those files.
What is wrong with one file execution? It is easier to use for very small applications, which is what a beginner will want.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic