5

Hello I am on campus trying to compile a simple binary tree program .. our campus only has shell and I am using Linux over eclipse..

I have 2 class files in my current directory bintree.java and treetest.java

javac bintree.java treetest.java

this code creates multiple classes but what is my next step? ive searched everywhere theres not a lot of info on java Linux shell. thank you

user3349184
  • 123
  • 1
  • 2
  • 8

3 Answers3

7

If all of the java files you need to compile are in your directory you can

javac *.java 

And then

java NameOfClassWithMainMethod

Otherwise if you want to learn to work without an IDE I would suggest learning to use Maven or Gradle. They will abstract away a lot of the tedium of compiling a project, and if become a pro dev you'll need to know at least Maven anyway.

jeremyjjbrown
  • 7,268
  • 4
  • 38
  • 54
3
$ find -name "*.java" > sources.txt
$ javac @sources.txt
TheEwook
  • 10,477
  • 6
  • 32
  • 54
0

You might look at http://www.dummies.com/how-to/content/how-to-use-the-javac-command.html

When you run javac xxx.java xxy.java xxz.java you should get several .class files as a result. Is your problem really with running the javac or getting the resultant classes to run your program?

If so you may want to look here at another stackoverflow questin

Basically use java -cp classname for the class that has your "static Main()" in it

Community
  • 1
  • 1
ErstwhileIII
  • 4,691
  • 2
  • 21
  • 36
  • you are correct thank you for the help. however my program still does not run. I am on campus using a secure shell .. do you think its cuz im unable to reach the CLASSPATH correctly? I am seeing lots of info on CLASSPATH and I don't think mine is correct – user3349184 Feb 25 '14 at 02:10
  • If you are executing in the same directory you may not need a classpath argument – ErstwhileIII Feb 25 '14 at 02:15
  • your help has been great thank you. godspeed friend. – user3349184 Feb 25 '14 at 02:21