Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Ronnie Mccoy   on Jul 16 In Java Category.

  
Question Answered By: Edwin Chavez   on Jul 16

sounds like you don't have a cygwin problem but a typical java  problem. I don't
know what your experience with java is but what you described sounds like a
typical classpath problem that most beginners have.

If you have HelloWorld.java NOT in a package you should compile it with a
command like:
$ javac HelloWorld.java
to run  it you would use the command:
$ java -classpath . HelloWorld
The "-classpath ." tells the java virtual machine to look in the current
directory for *.class files.

If you have HelloWorld.java PACKAGED in com.initech, you should compile it with
a command like:
$ javac -d . HelloWorld.java
the "-d ." will create the directories will put the HelloWorld.class file in
directories ./com/initech/HelloWorld.class. To run it you would use the
command:
$ java -classpath . com.initech.HelloWorld
The "-classpath ." tells the java virtual machien to look in the current
directory for *.class files. Because the file to execute is
"com.initech.HelloWord" the java virtual machine will look for the
HelloWorld.class file in a com/initech/ directory.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Cygwin Or get search suggestion and latest updates.


Tagged: