This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Command line runs it, Eclipse does not :-(

 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy New Year JavaRanchars,
I am not new in Java, but very new in Eclipse.

I am facing a problem that seems to be very simple and common. But for last 3 days it driving me nuts. Kindly get me off the bottle neck.

I have a directory structure as follows

Under PbandPackage I put one file called Tools.java having code as follows:


Now I have anther file named Test.java under path c:\JavaProgs havng code as follows:-


By the way, eclipse underlines the word Tools with red.

I have added the following build path to my project in eclipse: c:\abcd\efgh

But even doing so I cannot run the Test.java from eclipse. The following error occurs:


But I can run the file from writing the following commands:


But surprisingly enough the fact is that, just after succesfully run from command if I hit the run button from eclipse the folloing error comes:


If proceed now then I get the correct output.

Kindly tell me just where I am going wrong. Please.
 
Manoj Agnihotri
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This errors is just because your class path is not configured correctly.


This code means PbandPackage must be at same level as Test Class.
Means :
-Test.class
-PbandPackage-Tools.class

or you can include class files in Project Class path :
Project Properties -> Build Path -> Libraries -> Add Class Folder
and Select Folder where you PbandPackage contains class file.

and now run your Tools.java file.



..........



But in case of Eclipse its very easy to create a Java Project.
1. Create a new Java Project
2. Create src folder for your project.
3. Create packages.
4. Import required classes by Pressing Ctrl + O
5. run your programs.
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prosenjit Banerjee:

I have added the following build path to my project in eclipse: c:\abcd\efgh

But even doing so I cannot run the Test.java from eclipse.


So, as I told, I added the path in the Build path. Still it does not run. Please tell me where am I going wrong.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic