Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Basic question about compiling

Reply
Thread Tools

Basic question about compiling

 
 
simplicity
Guest
Posts: n/a
 
      02-10-2012
I know this is kind of basic but somehow the solution escapes me.

I have the applet which is supposed to hook up with the hardware
attach to the computer. The hook-up interface is available in the
external JAR archive called sbsdk.jar. So, I compile the applet with
the following command:

javac -d %DST% ^
-classpath %CLASSPATH_1%;%CLASSPATH_2% ^
%SRC%\MyApplet.java >%DST%\MyApplet.log 2>%DST%\MyApplet.err

where
%CLASSPATH_1% points to the location of the sbsdk.jar, namely "C:\Users
\User\\Java\lib\sbsdk.jar"
and
%CLASSPATH_2% points to "%JRE%\lib\plugin.jar" (for JSObject to
communicate with javascript in the page).

OK, so far so good. Applet compiles with no issues. But that's where
it ends. When I load the HTML file containing the applet into a
browser I am getting the exception

Exception in thread "thread applet-MyApplet.class-1"
java.lang.NoClassDefFoundError: com.<blah-blah>.sbsdk/SBSDKListener

Luckily, I have the access to the sbsdk.jar source code. When I copy
the folder structure containing compiled classes of sbsdk (com\<blah-
blah>\sbsdk), my applet loads and everything works as expected.

Can someone help me understand why this is happening? I know that this
is generally caused by SBSDKListener class not being available at the
run time (while it is available at compile time, hence no build
errors) but I do not understand what it means in practical terms.

 
Reply With Quote
 
 
 
 
Knute Johnson
Guest
Posts: n/a
 
      02-10-2012
On 2/10/2012 8:12 AM, simplicity wrote:
> I know this is kind of basic but somehow the solution escapes me.
>
> I have the applet which is supposed to hook up with the hardware
> attach to the computer. The hook-up interface is available in the
> external JAR archive called sbsdk.jar. So, I compile the applet with
> the following command:
>
> javac -d %DST% ^
> -classpath %CLASSPATH_1%;%CLASSPATH_2% ^
> %SRC%\MyApplet.java>%DST%\MyApplet.log 2>%DST%\MyApplet.err
>
> where
> %CLASSPATH_1% points to the location of the sbsdk.jar, namely "C:\Users
> \User\\Java\lib\sbsdk.jar"
> and
> %CLASSPATH_2% points to "%JRE%\lib\plugin.jar" (for JSObject to
> communicate with javascript in the page).
>
> OK, so far so good. Applet compiles with no issues. But that's where
> it ends. When I load the HTML file containing the applet into a
> browser I am getting the exception
>
> Exception in thread "thread applet-MyApplet.class-1"
> java.lang.NoClassDefFoundError: com.<blah-blah>.sbsdk/SBSDKListener
>
> Luckily, I have the access to the sbsdk.jar source code. When I copy
> the folder structure containing compiled classes of sbsdk (com\<blah-
> blah>\sbsdk), my applet loads and everything works as expected.
>
> Can someone help me understand why this is happening? I know that this
> is generally caused by SBSDKListener class not being available at the
> run time (while it is available at compile time, hence no build
> errors) but I do not understand what it means in practical terms.
>


Do you have an archive statement in your APPLET tag that lists all the
jar files?

http://docs.oracle.com/javase/1.4.2/...sc/applet.html

--

Knute Johnson
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      02-10-2012
Knute Johnson wrote:
> simplicity wrote:
> > I know this is kind of basic but somehow the solution escapes me.
> >
> > I have the applet which is supposed to hook up with the hardware
> > attach to the computer. The hook-up interface is available in the
> > external JAR archive called sbsdk.jar. So, I compile the applet with
> > the following command:
> >
> > javac -d %DST% ^
> > -classpath %CLASSPATH_1%;%CLASSPATH_2% ^
> > %SRC%\MyApplet.java>%DST%\MyApplet.log 2>%DST%\MyApplet.err
> >
> > where
> > %CLASSPATH_1% points to the location of the sbsdk.jar, namely "C:\Users
> > \User\\Java\lib\sbsdk.jar"
> > and
> > %CLASSPATH_2% points to "%JRE%\lib\plugin.jar" (for JSObject to
> > communicate with javascript in the page).
> >
> > OK, so far so good. Applet compiles with no issues. But that's where


So far all you've done is specify the compile-time classpath.

> > it ends. When I load the HTML file containing the applet into a
> > browser I am getting the exception
> >
> > Exception in thread "thread applet-MyApplet.class-1"
> > java.lang.NoClassDefFoundError: com.<blah-blah>.sbsdk/SBSDKListener


Because you did not provide the JAR to the runtime classpath!

You need to study the Java tutorial.

> > Luckily, I have the access to the sbsdk.jar source code. When I copy
> > the folder structure containing compiled classes of sbsdk (com\<blah-
> > blah>\sbsdk), my applet loads and everything works as expected.


Your expectations are what are at fault.

You must provide the dependencies *at run-time*.

> > Can someone help me understand why this is happening? I know that this


We can tell you why this is happening; we cannot help you understand it.

> > is generally caused by SBSDKListener class not being available at the
> > run time (while it is available at compile time, hence no build
> > errors) but I do not understand what it means in practical terms.


It means, in practical terms, that you neglected to provide the applet with
its dependencies. Consider Knute's question:

> Do you have an archive statement in your APPLET tag that lists all the
> jar files?
>
> http://docs.oracle.com/javase/1.4.2/...sc/applet.html


Presumably he linked you to ancient docs to make the point that nothing has
changed in this area for a very long time.

You should read the tutorials and other documentation.

--
Lew
 
Reply With Quote
 
simplicity
Guest
Posts: n/a
 
      02-10-2012
On Feb 10, 10:00*am, Knute Johnson <nos...@knutejohnson.com> wrote:
> On 2/10/2012 8:12 AM, simplicity wrote:
>
>
>
>
>
>
>
>
>
> > I know this is kind of basic but somehow the solution escapes me.

>
> > I have the applet which is supposed to hook up with the hardware
> > attach to the computer. The hook-up interface is available in the
> > external JAR archive called sbsdk.jar. So, I compile the applet with
> > the following command:

>
> > javac -d %DST% ^
> > * * * *-classpath %CLASSPATH_1%;%CLASSPATH_2% ^
> > * * * *%SRC%\MyApplet.java>%DST%\MyApplet.log 2>%DST%\MyApplet.err

>
> > where
> > %CLASSPATH_1% points to the location of the sbsdk.jar, namely "C:\Users
> > \User\\Java\lib\sbsdk.jar"
> > and
> > %CLASSPATH_2% points to "%JRE%\lib\plugin.jar" (for JSObject to
> > communicate with javascript in the page).

>
> > OK, so far so good. Applet compiles with no issues. But that's where
> > it ends. When I load the HTML file containing the applet into a
> > browser I am getting the exception

>
> > Exception in thread "thread applet-MyApplet.class-1"
> > java.lang.NoClassDefFoundError: com.<blah-blah>.sbsdk/SBSDKListener

>
> > Luckily, I have the access to the sbsdk.jar source code. *When I copy
> > the folder structure containing compiled classes of sbsdk (com\<blah-
> > blah>\sbsdk), my applet loads and everything works as expected.

>
> > Can someone help me understand why this is happening? I know that this
> > is generally caused by SBSDKListener class not being available at the
> > run time (while it is available at compile time, hence no build
> > errors) but I do not understand what it means in practical terms.

>
> Do you have an archive statement in your APPLET tag that lists all the
> jar files?
>
> http://docs.oracle.com/javase/1.4.2/...sc/applet.html
>
> --
>
> Knute Johnson


I do, but I only specify MyApplet.jar there. Does it mean that I
should have sbsdk.jar added to archive attribute?

How about plugin.jar? Obviously, I do not have the access to its
compiled classes but this one loads without complains. What's the
difference?
 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      02-10-2012
On 2/10/2012 11:26 AM, simplicity wrote:
> I do, but I only specify MyApplet.jar there. Does it mean that I
> should have sbsdk.jar added to archive attribute?


If you are using classes from sbsdk.jar at runtime, you need to include
that file in the archive statement.

> How about plugin.jar? Obviously, I do not have the access to its
> compiled classes but this one loads without complains. What's the
> difference?


I'm not familiar with what plugin.jar does so I don't know if it would
be included by some other method. So I would try including it.

--

Knute Johnson
 
Reply With Quote
 
simplicity
Guest
Posts: n/a
 
      02-10-2012
On Feb 10, 10:29*am, Lew <lewbl...@gmail.com> wrote:
> Knute Johnson wrote:
> > simplicity wrote:
> > > I know this is kind of basic but somehow the solution escapes me.

>
> > > I have the applet which is supposed to hook up with the hardware
> > > attach to the computer. The hook-up interface is available in the
> > > external JAR archive called sbsdk.jar. So, I compile the applet with
> > > the following command:

>
> > > javac -d %DST% ^
> > > * * * *-classpath %CLASSPATH_1%;%CLASSPATH_2% ^
> > > * * * *%SRC%\MyApplet.java>%DST%\MyApplet.log 2>%DST%\MyApplet.err

>
> > > where
> > > %CLASSPATH_1% points to the location of the sbsdk.jar, namely "C:\Users
> > > \User\\Java\lib\sbsdk.jar"
> > > and
> > > %CLASSPATH_2% points to "%JRE%\lib\plugin.jar" (for JSObject to
> > > communicate with javascript in the page).

>
> > > OK, so far so good. Applet compiles with no issues. But that's where

>
> So far all you've done is specify the compile-time classpath.
>
> > > it ends. When I load the HTML file containing the applet into a
> > > browser I am getting the exception

>
> > > Exception in thread "thread applet-MyApplet.class-1"
> > > java.lang.NoClassDefFoundError: com.<blah-blah>.sbsdk/SBSDKListener

>
> Because you did not provide the JAR to the runtime classpath!
>
> You need to study the Java tutorial.
>
> > > Luckily, I have the access to the sbsdk.jar source code. *When I copy
> > > the folder structure containing compiled classes of sbsdk (com\<blah-
> > > blah>\sbsdk), my applet loads and everything works as expected.

>
> Your expectations are what are at fault.


I guess you are right. When I post the question on the public forum my
expectations are (1) get the answer, regardless of how trivial, basic
and obvious it might be or (2) get a gibberish like the stuff you
spent time on creating.

"Go do your research" is a typical response of a clueless buffoon
whose only characteristic is that he/she cannot keep his/her mouth
shut.

> You must provide the dependencies *at run-time*.


Didn't I say that I know WHAT is causing it? I thought I did. What I
do not know is WHY and HOW to fix it.

Anyway, thanks for your time you spent typing your response. Sorry to
state it to you though that it is useless. I always DO my research and
if I decide to go public with questions it means I did not find the
answer myself. I suppose the same applies to majority of folks here
and my advise to you is: give people a bit of a slack.

> > > Can someone help me understand why this is happening? I know that this


> We can tell you why this is happening; we cannot help you understand it.


And also thanks for your attempt to point out to me how really stupid
I am. I am going to try to improve...

 
Reply With Quote
 
simplicity
Guest
Posts: n/a
 
      02-10-2012
On Feb 10, 12:37*pm, Knute Johnson <nos...@knutejohnson.com> wrote:
> On 2/10/2012 11:26 AM, simplicity wrote:
>
> > I do, but I only specify MyApplet.jar there. Does it mean that I
> > should have sbsdk.jar added to archive attribute?

>
> If you are using classes from sbsdk.jar at runtime, you need to include
> that file in the archive statement.
>
> > How about plugin.jar? Obviously, I do not have the access to its
> > compiled classes but this one loads without complains. What's the
> > difference?

>
> I'm not familiar with what plugin.jar does so I don't know if it would
> be included by some other method. *So I would try including it.


It contains JSObject which provides the interface between the applet
and Javascrip so I can pass the info back and forth between the applet
and the HTML.

Thanks for the hint. I am going to try.
 
Reply With Quote
 
simplicity
Guest
Posts: n/a
 
      02-10-2012
On Feb 10, 12:37*pm, Knute Johnson <nos...@knutejohnson.com> wrote:
> On 2/10/2012 11:26 AM, simplicity wrote:
>
> > I do, but I only specify MyApplet.jar there. Does it mean that I
> > should have sbsdk.jar added to archive attribute?

>
> If you are using classes from sbsdk.jar at runtime, you need to include
> that file in the archive statement.
>
> > How about plugin.jar? Obviously, I do not have the access to its
> > compiled classes but this one loads without complains. What's the
> > difference?

>
> I'm not familiar with what plugin.jar does so I don't know if it would
> be included by some other method. *So I would try including it.
>
> --
>
> Knute Johnson


Including sbsk.jar in the archive

<applet code="MyApplet.class" archive="MyApplet.jar,sbsdk.jar"
mayscript
width="700" height="500">
</applet>

works.

For some reason I do not need to spec plugin.jar. Well, this is a
"system" archive so maybe there is a global setting of JVM to link it.
Anyway...

Appreciate your help. Thanks.
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-10-2012
On Friday, February 10, 2012 11:48:13 AM UTC-8, simplicity wrote:
> On Feb 10, 10:29*am, Lew <lewbl...@gmail.com> wrote:
> > Knute Johnson wrote:
> > > simplicity wrote:
> > > > I know this is kind of basic but somehow the solution escapes me.

> >
> > > > I have the applet which is supposed to hook up with the hardware
> > > > attach to the computer. The hook-up interface is available in the
> > > > external JAR archive called sbsdk.jar. So, I compile the applet with
> > > > the following command:

> >
> > > > javac -d %DST% ^
> > > > * * * *-classpath %CLASSPATH_1%;%CLASSPATH_2% ^
> > > > * * * *%SRC%\MyApplet.java>%DST%\MyApplet.log 2>%DST%\MyApplet.err

> >
> > > > where
> > > > %CLASSPATH_1% points to the location of the sbsdk.jar, namely "C:\Users
> > > > \User\\Java\lib\sbsdk.jar"
> > > > and
> > > > %CLASSPATH_2% points to "%JRE%\lib\plugin.jar" (for JSObject to
> > > > communicate with javascript in the page).

> >
> > > > OK, so far so good. Applet compiles with no issues. But that's where

> >
> > So far all you've done is specify the compile-time classpath.
> >
> > > > it ends. When I load the HTML file containing the applet into a
> > > > browser I am getting the exception

> >
> > > > Exception in thread "thread applet-MyApplet.class-1"
> > > > java.lang.NoClassDefFoundError: com.<blah-blah>.sbsdk/SBSDKListener

> >
> > Because you did not provide the JAR to the runtime classpath!
> >
> > You need to study the Java tutorial.
> >
> > > > Luckily, I have the access to the sbsdk.jar source code. *When I copy
> > > > the folder structure containing compiled classes of sbsdk (com\<blah-
> > > > blah>\sbsdk), my applet loads and everything works as expected.

> >
> > Your expectations are what are at fault.

>
> I guess you are right. When I post the question on the public forum my
> expectations are (1) get the answer, regardless of how trivial, basic
> and obvious it might be or (2) get a gibberish like the stuff you
> spent time on creating.
>
> "Go do your research" is a typical response of a clueless buffoon
> whose only characteristic is that he/she cannot keep his/her mouth
> shut.


So you're saying that reading the documentation is not a good idea?

> > You must provide the dependencies *at run-time*.

>
> Didn't I say that I know WHAT is causing it? I thought I did. What I
> do not know is WHY and HOW to fix it.


You asked specifically for help understanding the issue. Another respondenthad
given you a recipe for repair; I did not see any point in wasting your time
repeating his good advice. However, that only answered part of your question.
You also asked, "Can someone help me understand why this is happening?" I am so
very sorry I took your question seriously and tried to answer it more fully..
I guess I was under the assumption that you actually wanted the information
that you requested.

> Anyway, thanks for your time you spent typing your response. Sorry to
> state it to you though that it is useless. I always DO my research and
> if I decide to go public with questions it means I did not find the
> answer myself. I suppose the same applies to majority of folks here
> and my advise [sic] to you is: give people a bit of a slack.


Your answer showed no signs of you having read or understood the very basic
need in Java to have the JAR present at runtime as well as at compile time.
Under the circumstances, telling you what to research and where seemed
appropriate. Now, untwist your knickers, please.

> > > > Can someone help me understand why this is happening? I know that this

>
> > We can tell you why this is happening; we cannot help you understand it..

>
> And also thanks for your attempt to point out to me how really stupid
> I am. I am going to try to improve...


With that level of response to the help you received, I doubt it.

--
Lew
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      02-10-2012
On 10.02.2012 20:37, Knute Johnson wrote:
> On 2/10/2012 11:26 AM, simplicity wrote:
>> I do, but I only specify MyApplet.jar there. Does it mean that I
>> should have sbsdk.jar added to archive attribute?

>
> If you are using classes from sbsdk.jar at runtime, you need to include
> that file in the archive statement.


But that's not the only option. The Jar's classpath would be another.

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Cross-compiling error when compiling 2.6.1... Garrett Cooper Python 0 02-24-2009 09:47 PM
Cross-compiling error when compiling 2.6.1... Garrett Cooper Python 0 02-24-2009 08:55 PM
What is the difference between Visual Basic.NET and Visual Basic 6? Jimmy Dean Computer Support 3 07-25-2005 07:05 AM
Compiling when libedit is in path Is there a trick to compiling Ruby when libedit must exist in the search path? Can you statically link to readline 5.0 in some manner? -- Lon Baker Lon Baker Ruby 1 03-21-2005 08:57 AM
Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET Jaime MCSD 2 09-20-2003 05:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57