aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Launching From Command Line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Launching From Command Line" Watch "Launching From Command Line" New topic
Author

Launching From Command Line

Mehmet Atlihan
Greenhorn

Joined: Mar 03, 2004
Posts: 20
Hello all
I have finished coding\documentation and about to submit the assignment
I am keeping the generated binary codes in a seperate directory called classes. Actually thats what JBuilder did for me and I believe it is a good
practise to seperate the implementation and the class files so I am planning to keep it that way.
But I am experiencing problems when I attempt to compile\launch the application from the command line. What I did was to aggreate all the class files in a jar file and put it in the working directory.That did not work
so I add an entry which points to the *.jar file I have created in the classpath variable of the OS. It didnt work either. Yet I believe that alone might cause to fail the exam since it requires the grader to edit their classpath manually.
I will appreciate any ideas from those who had similar package hierarchy
regarding how they handled command line execution of the application. Although it is not clear according to the specifications I have , I dont think it is a good idea to enforce the grader to edit his classpath enviroment variable manually isnt it?
Thank You In Advance
Mehmet
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Mehmet,
Welcome to this forum.
Originally posted by Mehmet Atlihan:
Although it is not clear according to the specifications I have , I dont think it is a good idea to enforce the grader to edit his classpath enviroment variable manually isnt it?

You are absolutely right, it is in fact a very bad idea to force the grader to edit his classpath environment variable manually. I suspect the grader might think it is such a bad idea that he might automatically fail your project.
The good news is that this is relatively easy to fix. One of the main purposes of using an executable jar file is that it frees the user from classpath concerns. I'm assuming you used packages in your development. Let's say you have three packages: suncertify.db, suncertify.rmi, and suncertify.client. Let's further assume that all your *.class files are in a classes directory. The contents of that classes directory should look like this:

where + name is a directory.
Then, the following command should create a runme.jar:

The runme.jar should then be runnable on any computer that can support a JVM. That is, anywhere you can do "java -version" you should be able to do "java -jar runme.jar alone". It should not matter how the classpath is set since you will not be referencing it.


Regards, George
SCJP, SCJD, SCWCD, SCBCD
Mehmet Atlihan
Greenhorn

Joined: Mar 03, 2004
Posts: 20
Thanks George I do appreciate it . One last concern I have is (again it is not clear according to the specifications but a vital one) about the package hierarcy.
According to the specifications :

Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:

And again :
All elements of your submission must be packaged in a single JAR file. The JAR file must have the following layout and contents in its root:
..........................
-A directory called code, containing all the source code and related parts of your project. You must create subdirectories within this to reflect your package structure and distribute your source files within those directories.

Intutievely I have created suncertify.db package under the code package.
Is that right or suncertify.db should be a seperate package under the jar file we have created?
What confused me was if all source files should go to the code directory
then the suns package name should not be suncertify.db rather code.suncertify.db, else not all the source files go to the code directory
Regards
Mehmet
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Mehmet,
It's a little bit confusing. Let's see if we can clarify. While it's true that a package hierarchy is represented in a directory structure, the entire directory structure may not be part of the package hierarchy. Let's look at an example:

We would expect this class to be in file named Data.java. We would also expect that it is in a directory structure that looks like this:

But, that directory structure that we just described can be found anywhere. So for example, the directory structure we just described could be in the code directory as follows:

So if you say all your source code is in the code directory, because your code is contained within packages, what you are really saying is that the source code in the code directory looks like this:

That is, the source code package hierarchy is located in the code directory.
So, if you want to know where the suncertify.db.Data.java file is located you could say that it is in the code directory. Within the code directory you would expect to find the package hierarchy. That is, you would expect to find a suncertify directory, and within that you would expect to find a db directory, and within that you would expect to find the Data.java file.
[ March 15, 2004: Message edited by: George Marinkovich ]
Mehmet Atlihan
Greenhorn

Joined: Mar 03, 2004
Posts: 20
Okay George I got the point.I can comfortably upload the assignment after testing it on some other OS`s anymore
Thanks & Regards
Mehmet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Launching From Command Line
 
Similar Threads
packaging submission
Accessing class in jar
Just got my result 145/155
Pain with classpaths..
Tryin' to create a small MS SQL Java Application