get startet with java (package)
I have a book about java that tells me that if I use:
"package mypack.something" i have to store the class in a directory like C:Java\mypack\something I can't find out how that works running linux. I tried the analog version but the shells says 'wrong name' or 'can't find class' depending on which directory I'm in. Does someone have the time to give me a hint? Would be great! Cheers J. |
First thing you should know is that EVEN UNDER WINDOWS, Java cares about file name capitalization. A class named Xyz has to be in a file named Xyz.java (NOT xyz.java), and compiles to Xyz.class.
Let's say I have a java file for package com.mousetech and the class it defines is named "Test". If I do a compile: javac -d . Test.java I'll see the following results in a directory tree view: Test.java com <dir> | mousetech <dir> | Test.class So I can run it by saying: java -classpath . com.mousetech.Test Note that "." means the current (working) directory, that to run the application you have to give its complete name (package name and all - peoperly capitalized!). and that you don't need to say ".class" at the end. |
:) Thanks a lot ! It works now.
|
All times are GMT -5. The time now is 11:41 PM. |