473,383 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

About executing class files....

539 512MB
I have a class file that instantiates an object from a jar file
or simply a class file inside the jar file is used as part of the simple program....

When we use the the jar file in JSP, we simply put the complete filepath of the class files inside the manifest file(Name:) an enable the Java-Bean setting( set to true) then solved....(ready to use)

What comes to mind is, im taking the short road, without an experience of running a class file that accessing another classfile(which is inside the jar file)...( Running a unjarred stand-alone application that uses another classfile inside the jar)

i know how to compile it, javac -cp jarname.jar test.java

but, i don't know how to execute it.....

The jar file already been set-up, the index.list and the Name set to common...
Which i found on a tutorial on the net....

But, in my case, i've got nothing on the web.....

Please let me know experts what is the pattern for executing such classfile like this scenario...... or a url that directly teach me how to deal with it....

Waiting,
sukatoa.
Jul 27 '08 #1
19 1956
JosAH
11,448 Expert 8TB
I don't understand your question. What do you mean by 'that instantiates an
object from a jar file'? A .jar file simply contains classes and other resources.

kind regards,

Jos
Jul 27 '08 #2
sukatoa
539 512MB
I don't understand your question. What do you mean by 'that instantiates an
object from a jar file'? A .jar file simply contains classes and other resources.

kind regards,

Jos
Apologize!!!! :(

Actually, im on the experiment now,

I have created an API for my JSP project.....
Which is jarred and no problem about that.....

But i have a problem when im gonna use that on a stand-along program

What i really don't know is the following:

suppose i have a class file named SQLDriver that was jarred....(MyJar.jar)
and i have a class file(not jarred) named SQLDriverTest

im going to use that SQLDriver class that was jarred from my SQLDriverTest

javac -classpath MyJar.jar SQLDruverTest,java
successfully compiled

The problem is, i don't know how to execute the SQLDriverTest

Can you teach me how to do it Jos?
This is really an urgent, i need to distribute this to my groupmates as soon as possible, because i have created a stand-alone application that updates the database every 10 seconds and they must use that to be able test what they have done in their part.

The stand-alone app will do the following:

Delete those expired reservations
Move those guests that suspectedly a criminal/terrorists
Do Admin's priviledge
Setting-up a database schema, its table and the columns
Jul 27 '08 #3
JosAH
11,448 Expert 8TB
The JVM doesn't care where those classes come from: either from their own
file or read from a .jar file or whatever; that is the concern of the ClassLoader.
The SystemClassLoader (the one you use by default) uses a 'classpath' variable
for that purpose. That variable is a list of directories and/or .jar files. If that
ClassLoader needs to load a file it checks the classpath and searches all those
directories and/or mentioned .jar files for the wanted class.

If, e.g. you store your .class files in directory /foo and your myJar.jar file in a
directory /bar you should use a command line like this:

Expand|Select|Wrap|Line Numbers
  1. java -cp=/foo;/bar/myJar.jar MyClass
  2.  
The class MyClass can be stored in that .jar or in directory /foo; it doesn't matter
and the ClassLoader will look in that directory or .jar file for all the classes it
needs to load.

kind regards,

Jos

ps use a colon instead of a semicolon for the separator of the elements in the
classpath variable if you're using Un*x.
Jul 27 '08 #4
sukatoa
539 512MB
i got an error here.....

NoClassDefFoundError test

test is the SQLDriverTest

im compiling them on the same folder

java -cp DMA_OpenSource_API.jar test
is that correct?

or should i put them in a sub folder? like what you've suggested?
Jul 27 '08 #5
JosAH
11,448 Expert 8TB
No that is not correct because you're not compiling anything there; you're trying
to fire up the JVM.

kind regards,

Jos

ps. also study this.
Jul 27 '08 #6
sukatoa
539 512MB
No that is not correct because you're not compiling anything there; you're trying
to fire up the JVM.

kind regards,

Jos
I forgot to mention,

It was already compiled using

javac -cp DMA_OpenSource_API.jar test.java


and now, my latest reply doesn't seem to work....
java -cp DMA_OpenSource_API.jar test

Error: NoClassDefFoundError: test
Jul 27 '08 #7
JosAH
11,448 Expert 8TB
I forgot to mention,

It was already compiled using

javac -cp DMA_OpenSource_API.jar test.java


and now, my latest reply doesn't seem to work....
java -cp DMA_OpenSource_API.jar test
Hrm; is that test class a class in a package? Also be sure to include the current
directory in your classpath like so:

Expand|Select|Wrap|Line Numbers
  1. java -cp DMA_OpenSource_API.jar;. test
  2.  
kind regards,

Jos

ps. see the ps I added a bit later in my previous reply.
Jul 27 '08 #8
sukatoa
539 512MB
Hrm; is that test class a class in a package? Also be sure to include the current
directory in your classpath like so:

Expand|Select|Wrap|Line Numbers
  1. java -cp DMA_OpenSource_API.jar;. test
  2.  
kind regards,

Jos

ps. see the ps I added a bit later in my previous reply.

hahahahahahhhh....... You're a God like Jos,

You got it, the dot ( . ) is i really don't know if they are on the same folder and im also on that folder using cmd......

Thank you very much Jos...... :)
Jul 27 '08 #9
JosAH
11,448 Expert 8TB
hahahahahahhhh....... You're a God like Jos,
I know ;-)

You got it, the dot ( . ) is i really don't know if they are on the same folder and im also on that folder using cmd......

Thank you very much Jos...... :)
You're welcome of course but also read that link I supplied in reply #6 so that
you'll understand completely what that classpath is all about.

kind regards,

Jos
Jul 27 '08 #10
sukatoa
539 512MB
You're welcome of course but also read that link I supplied in reply #6 so that
you'll understand completely what that classpath is all about.

kind regards,

Jos
Yes, i will.......................... :)
Jul 27 '08 #11
sukatoa
539 512MB
I got new problem here......

I've jarred my test.class, added Class-Path: DMA_OpenSouce_API.jar(with the com folder added)
successfully run.....

Now, I would like to have that mysql-connector-java-5.0.8-bin.jar independently.....
Instead of adding the com folder(from mysql-connector-java-5.0.8-bin.jar) into my DMA_OpenSouce_API.jar,

Now, i don't know how to add another path here.....

I've made: Class-Path: DMA_OpenSouce_API.jar; mysql-connector-java-5.0.8-bin.jar(newline)

to the manifest(From my test.jar), but it doesn't work...... How can i reproduce that one?
Jos, what can you recommend about this?

waiting,
sukatoa

PostScript: The test.jar, DMA_OpenSouce_API.jar and the mysql-connector-java-5.0.8-bin.jar are on the same folder.....
Jul 28 '08 #12
r035198x
13,262 8TB
I got new problem here......

I've jarred my test.class, added Class-Path: DMA_OpenSouce_API.jar(with the com folder added)
successfully run.....

Now, I would like to have that mysql-connector-java-5.0.8-bin.jar independently.....
Instead of adding the com folder(from mysql-connector-java-5.0.8-bin.jar) into my DMA_OpenSouce_API.jar,

Now, i don't know how to add another path here.....

I've made: Class-Path: DMA_OpenSouce_API.jar; mysql-connector-java-5.0.8-bin.jar(newline)

to the manifest(From my test.jar), but it doesn't work...... How can i reproduce that one?
Jos, what can you recommend about this?

waiting,
sukatoa

PostScript: The test.jar, DMA_OpenSouce_API.jar and the mysql-connector-java-5.0.8-bin.jar are on the same folder.....
Read here.
not Jos
Jul 28 '08 #13
sukatoa
539 512MB
Ok, i got it, here is the link......

No semi-colon anymore......

PS: Thanks for the url r035198x, I think google doesn't know what i really like to look for..... :(
Jul 28 '08 #14
sukatoa
539 512MB
Ok, i got it, here is the link......

No semi-colon anymore......

PS: Thanks for the url r035198x, I think google doesn't know what i really like to look for..... :(
Ok, here is a new problem again,

My DMA_OpenSouce_API.jar wants to access a class from mysql-connector-java-5.0.8-bin.jar.... not my test.jar....

So, in common-sense, i should not add the classpath for the mysql-connector-java-5.0.8-bin.jar in my test.jar, instead, i should add it from the manifest of my DMA_OpenSource_API.jar......

But i don't know how....

Here is the content of DMA_OpenSouce_API.jar

MANIFEST.MF:
Expand|Select|Wrap|Line Numbers
  1. Manifest-Version: 1.0
  2. Specification-Title: DMA OpenSource™ API Specification
  3. Created-By: 1.0 (DMA OpenSource™ Inc)
  4. Implementation-Title: Java Runtime Environment
  5.  
  6. Name: common
  7.  
INDEX.LIST
Expand|Select|Wrap|Line Numbers
  1. JarIndex-Version: 1.0
  2.  
  3. DMA_OpenSource_API.jar
  4. dma
  5. dma/constants
  6. dma/data
  7. dma/data/secure
  8. dma/db
  9. dma/files
  10. dma/printer
  11. dma/system
  12. dma/time
  13. dma/utility
  14. dma/utility/converter
Now, i don't know where to put such Header "Class-Path", since all the tutorials i saw on the web is all about dealing such scenario with the main-class

Please do correct me if i forgot something here....

Waiting again,
sukatoa
Jul 28 '08 #15
r035198x
13,262 8TB
I don't see a ClassPath entry at all in that manifest ...
Jul 28 '08 #16
sukatoa
539 512MB
I don't see a ClassPath entry at all in that manifest ...
yah, i've attempted to add Class-Path below the Name: common, (ERROR)

I also tried to add the contents of the INDEX.LIST from connectorJ.jar into my DMA_OpenSource_API.jar, (ERROR)

That is why i didn't add the classpath their, since all of my attempts are not successful.....

@123: By the way, im already a year in Java, but i still don't see any Libraries that connects to other libraries, is it already exists? or am i too innocent about this?

Please let me know,

my resolution is to break the dma/db from the DMA_OpenSouce_API.jar and add it to a new jar that contains the com folder(where the Driver.class can be found), since it is all about simplifying database handling.....(My purpose is only for the scope of our project)

If i am innocent about "@123", then, sooner or later i will dive to that implementation again....

Thanks for all of your replies Jos and r035198x, That really helps.....

already have a peace of mind,
sukatoa
Jul 28 '08 #17
JosAH
11,448 Expert 8TB
Here's how I do it:

Expand|Select|Wrap|Line Numbers
  1. Manifest-Version: 1.0
  2. Created-By: DADID Systems
  3. Main-Class: IDEMain
  4. Class-Path: rpl.jar utilities.jar resources.jar rpldb.jar derby.jar
  5. Built-By: DADID Systems
  6. Name: RPL ide
  7. Specification-Title: RPL ide Application
  8. Specification-Version: 1.0
  9. Specification-Vendor: DADID Systems
  10. Implementation-Title: RPL ide Application
  11. Implementation-Version: 1.0
  12. Implementation-Vendor: DADID Systems
  13.  
The name of my little company is 'DADID Systems'. The application uses a couple
of jars, mentioned on the Class-Path: line. The IDEMain class has the main()
method and that class is present in one of the mentioned jars. A few of the
name dropping lines can be left out of course.

kind regards,

Jos
Jul 28 '08 #18
sukatoa
539 512MB
Here's how I do it:

Expand|Select|Wrap|Line Numbers
  1. Manifest-Version: 1.0
  2. Created-By: DADID Systems
  3. Main-Class: IDEMain
  4. Class-Path: rpl.jar utilities.jar resources.jar rpldb.jar derby.jar
  5. Built-By: DADID Systems
  6. Name: RPL ide
  7. Specification-Title: RPL ide Application
  8. Specification-Version: 1.0
  9. Specification-Vendor: DADID Systems
  10. Implementation-Title: RPL ide Application
  11. Implementation-Version: 1.0
  12. Implementation-Vendor: DADID Systems
  13.  
The name of my little company is 'DADID Systems'. The application uses a couple
of jars, mentioned on the Class-Path: line. The IDEMain class has the main()
method and that class is present in one of the mentioned jars. A few of the
name dropping lines can be left out of course.

kind regards,

Jos
Thanks for your reply Jos,

I have a question,

Does any of your jars accesses one another except your main jar? or all of them are being used only at the main jar?

if not clear, please let me know,
Jul 28 '08 #19
JosAH
11,448 Expert 8TB
Thanks for your reply Jos,

I have a question,

Does any of your jars accesses one another except your main jar? or all of them are being used only at the main jar?
Yep, quite a lot of classes in one jar access/use other classes from the other jars.
That isn't a problem as long as those jars are mentioned in the classpath.

kind regards,

Jos
Jul 28 '08 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: lian | last post by:
Hi all, I have installed a web-based software written in php which needs that i should turn "register_globals" from off to on in the php.ini. There are some comments for register_globals in...
1
by: Phil | last post by:
Hi, I have my create statments for tables, procedures, views, etc in individual Transact-SQL script files (.sql). I wnat to write another script file that executes these scripts in the...
1
by: Xilo Musimene | last post by:
Hi there, I'm programming an archiving class and the archive is currently able to read files, concatenate them in one and compress the archive (or specific files that can be compressed) with the...
10
by: Skywise | last post by:
I keep getting the following error upon compiling: c:\c++ files\programs\stellardebug\unitcode.h(677) : error C2664: 'class istream &__thiscall istream::getline(char *,int,char)' : cannot convert...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
2
by: SLE | last post by:
Hi there, We have a class method which is invoked through Remoting/IIS. Within this class method, we need to get the physical path of the assembly (dll) in which the method is executing. we have...
2
by: LordChaos | last post by:
Dear all, I am a newbie in Java, I got the following problem: I am going through a list of directories. The programm looks inside each directory for specific files and writes them in an...
0
by: mosquito | last post by:
i created a bean class, remote interface,home class,client class and a local class,i made a jar out of it with all these classes. example, my package is named as "salejb". it is as follows...
2
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
I am executing an AJAX page method that is a long running task. After starting the first method, I execute a second page method to retrieve the status of the task. It works fine in an empty web...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.