Follow these steps :
Say the directory structure is this on my side, under C Drive
:
components-JWSFileChooserDemoProject
|
------------------------------------
| | | |
nbproject src build.xml manifest.mf
|
components
|
-------------------------------------------------
| | | |
images jars | |
JWSFileChooserDemo.java JWSFileChooserDemo.jnlp
Under components Directory
create a new Directory
called build
so now Directory - components
will have five thingies, instead of four i.e. build
, images
, jars
, JWSFileChooserDemo.java
and JWSFileChooserDemo.jnlp
.
Now first go to components Directory
.
To compile write this command :
C:components-JWSFileChooserDemoProjectsrccomponents>javac -classpath images*;jars*;build -d build JWSFileChooserDemo.java
Here inside -classpath
option, you are specifying that content of Directories
images
, jars
and build
is to be included while compiling JWSFileChooserDemo.java
. -d
option basically tells, as to where to place the .class
files.
Move to "build"
folder :
C:components-JWSFileChooserDemoProjectsrccomponents>cd build
Run the Program :
C:components-JWSFileChooserDemoProjectsrccomponentsuild>java -cp .;..images*;..jars* components.JWSFileChooserDemo
Here inside -cp
option .
represents, that look from the current position, ..images*
means, go one level up inside images Directory
, from the current location and get all its contents and the same goes for ..jars*
thingy too.
Now you will see it working, and giving the following output :
EDIT 1 :
Since you wanted to do it without -d
option of the Java Compiler - javac
. Considering the same directory structure, as before, move inside your components Directory
.
COMPILE with this command :
C:components-JWSFileChooserDemoProjectsrccomponents>javac -classpath images*;jars* JWSFileChooserDemo.java
Now manually create the package structure
in the File System
, i.e. create Directory components
and then move your .class
files created previously, inside this newly created components Directory
, and also add images
folder to this newly created components
folder.
Now Directory - components
will have five thingies, instead of four i.e. components(which further contains JWSFileChooserDemo.class , JWSFileChooserDemo$1.class and images folder)
, images
, jars
, JWSFileChooserDemo.java
and JWSFileChooserDemo.jnlp
.
RUN the program with this command :
C:components-JWSFileChooserDemoProjectsrccomponents>java -cp .;jars* components.JWSFileChooserDemo
This will give you the previous output, though, if you wanted to move as suggested before, again copy images
folder to the automatically generated components
folder, since I just looked inside the .java
and they using relative path
for it to work.
JUST THIS PARTICULAR SOLUTION, I AM ABOUT TO DESCRIBE WILL WORK FOR YOUR CASE ONLY :
If after javac
command given before, if you don't wanted to create any folder, then go one level up, i.e. outside components directory and use this command to run the program
C:components-JWSFileChooserDemoProjectsrc>java -cp .;componentsjars* components.JWSFileChooserDemo
If you don't wanted to