Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-12-2009, 12:07 PM
Member
 
Join Date: Jan 2009
Posts: 2
Rep Power: 0
MAILMIRZA is on a distinguished road
Default Compiling and using jar file for custom classes
Hi ,

I downloaded java classes available as attached file with this post


I un-zippped and saved the class files in sms folder.

I successfully compiled it using javac as below:

C:\Program Files\Java\jdk1.6.0_11\bin>javac sms\SMSClient.java sms\Sender.java sms\SerialConnection.java sms\SerialConnectionException.java sms\SerialParameters.java

then i created jar file using the command below:
C:\Program Files\Java\jdk1.6.0_11\bin>jar cf SMSClientpack.jar sms\Sender.class sms\SerialConnection$KeyHandler.class sms\SerialConnection.class sms\SerialConnectionException.class sms\SerialParameters.class sms\SMSClient.class

Then I placed that SMSClientpack.jar in

C:\Program Files\Java\jdk1.6.0_11\lib


Then i created a file with name DemoSMS.java to use above code

//DemoSms.java
import java.SMSClientpack.*;

public class DemoSms
{
public static void main(String args[])
{
SMSClient sc = new SMSClient();
sc.sendMessage("mycellnumber","Hello");
}

}
//ends here


It shows following error, please help where i am doing wrong?

C:\Program Files\Java\jdk1.6.0_11\bin>javac DemoSms.java
DemoSms.java:3: package java.SMSClientpack does not exist
import java.SMSClientpack.*;
^
DemoSms.java:10: cannot find symbol
symbol : class SMSClient
location: class DemoSms
SMSClient sc = new SMSClient();
^
DemoSms.java:10: cannot find symbol
symbol : class SMSClient
location: class DemoSms
SMSClient sc = new SMSClient();
^
3 errors


thanks,
Kashif
Attached Files:
File Type: zip sms.zip (9.0 KB, 8 views)
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-12-2009, 12:35 PM
Senior Member
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 473
Rep Power: 2
mtyoung is on a distinguished road
Default
SMSClientpack.jar is external jar, i think.

you may try to copy the jar to project directory
package it, and import it

and
compile using -classpath to point to to SMSClientpack.jar
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-12-2009, 01:12 PM
Member
 
Join Date: Jan 2009
Posts: 2
Rep Power: 0
MAILMIRZA is on a distinguished road
Default eclipse?
Thanks, Appreciate your help.
I am using notepad. Should I shift to Eclipse for this pupose or is there any other alternative?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-12-2009, 05:56 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,445
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
What mtyoung described is the best way to get practice it. You are trying to import that external jar file in java default package, something like this,

Quote:
import java.*;
It's not possible, not valid. What must import correct package according to your project placed.

Almost all IDEs able to link external jar files. If you are working on an IDE, it'll added the external jar files for you.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot read file while compiling!!! AMIT TAYADE New To Java 11 08-23-2008 01:02 PM
Able to find class file in WEB-INF/classes but not after add sub folders in class dir vitalstrike82 Web Frameworks 0 05-13-2008 07:16 AM
Declaring Custom File Extensions Jesdisciple JavaServer Pages (JSP) and JSTL 2 05-07-2008 11:44 PM
Poblem in Compiling a c++ file from a java program... Amit Kr. Mishra New To Java 0 11-06-2007 11:41 AM
How to use <,>,== on custom classes Bojevnik Advanced Java 4 10-29-2007 06:00 PM


All times are GMT +2. The time now is 09:47 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org