Results 1 to 6 of 6
- 03-20-2009, 10:11 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 92
- Rep Power
- 0
package statement in java files won't run outside of eclipse
I am learning eclipse and java concurrently.
Eclipse puts a package statement at the head of a class file. The class will compile and run inside of eclipse, but I can not run it from the command line (java myclass), although it compiles. I've found that removing the package statement allows the program to compile and run from the command line.
Can make the adjustment, but what is under the hood?
- 03-20-2009, 10:23 PM #2
thats because you don't have your CLASSPATH setup correctly. please post your classpath here. type echo %classpath% in cmd to find it.
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
-
Read the sun tutorial on how to compile and run your program and on use of package statement. This will answer all of your questions.
- 03-21-2009, 05:36 AM #4
Member
- Join Date
- Feb 2009
- Posts
- 92
- Rep Power
- 0
Found answer, still doesn't work
So, where in the sun tutorial do I find this information? Lots of material there, if I only knew where to look. I did go back to the the beginning and found some relevant information, even looked under common problems. Don't mind doing the leg work, but I am asking because I don't know where to look or what I missed the first go around. Finally found the answer in a dated version of "Core Java - Vol. 1" has a fairly comprehensive treatment of packages in chapter 4.
What I finally found out is that CLASSPATH + PACKAGE + somefile.class should evaluate to the location of "somefile.class". If there is a value in CLASSPATH, the current directory -> . <- is needed.
.;g:\workspace\LockObjects\src; is my class path. rdt_LockObj is my package.
Of course, now that I know all the answers, it still doesn't work.
What am I missing?
- 03-21-2009, 06:17 AM #5
did you put file.class file in folder:
g:\workspace\LockObjects\src\rdt_LockObj\file.clas s ?
also try running w/:
java rdt_LockObj.fileUSE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 03-21-2009, 05:19 PM #6
Member
- Join Date
- Feb 2009
- Posts
- 92
- Rep Power
- 0
Similar Threads
-
Importing a zipped package to Eclipse
By Abder-Rahman in forum EclipseReplies: 10Last Post: 02-24-2010, 05:26 PM -
importing .java files into eclipse
By nickl2002 in forum EclipseReplies: 1Last Post: 01-18-2009, 11:06 PM -
Multiple Eclipse package installation
By Robert Waltz in forum Advanced JavaReplies: 1Last Post: 11-23-2008, 12:24 AM -
org.eclipse.core package
By Eranga in forum Advanced JavaReplies: 2Last Post: 07-07-2008, 05:26 AM -
How to import a package in Eclipse?
By naipulb in forum New To JavaReplies: 2Last Post: 06-09-2008, 11:04 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks