Results 1 to 4 of 4
- 01-12-2009, 11:07 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 2
- Rep Power
- 0
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
- 01-12-2009, 11:35 AM #2
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
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
- 01-12-2009, 12:12 PM #3
Member
- Join Date
- Jan 2009
- Posts
- 2
- Rep Power
- 0
eclipse?
Thanks, Appreciate your help.
I am using notepad. Should I shift to Eclipse for this pupose or is there any other alternative?
- 01-12-2009, 04:56 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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,
It's not possible, not valid. What must import correct package according to your project placed.import java.*;
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.
Similar Threads
-
cannot read file while compiling!!!
By AMIT TAYADE in forum New To JavaReplies: 11Last Post: 08-23-2008, 12:02 PM -
Able to find class file in WEB-INF/classes but not after add sub folders in class dir
By vitalstrike82 in forum Web FrameworksReplies: 0Last Post: 05-13-2008, 06:16 AM -
Declaring Custom File Extensions
By Jesdisciple in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 05-07-2008, 10:44 PM -
Poblem in Compiling a c++ file from a java program...
By Amit Kr. Mishra in forum New To JavaReplies: 0Last Post: 11-06-2007, 10:41 AM -
How to use <,>,== on custom classes
By Bojevnik in forum Advanced JavaReplies: 4Last Post: 10-29-2007, 05:00 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks