Help needed! how to deploy java application

J

Jane Sfelc

I'm new to Java programming and need some help ...

I'm using NetBeans 4.0 beta2 to program Java applications. I can
compile and run them without trouble inside the IDE, but I can't get
them to work outside the IDE. I am using Swing components on my forms.

After building the application, the IDE generates PrimerForm.class,
PrimerForm$1.class, PrimerForm$2.class, PrimerForm$3.class and
PrimeraApp.jar files (just one class in my first project).

I am trying to run the application outside the IDE. When I type:

java PrimerForm

The results are:

Exception in thread "main" java.lang.NoClassDefFoundError: PrimerForm
(wrong nam
e: primeraapp/PrimerForm)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

When I type:

java -jar PrimeraApp.jar

The results are:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/netbe
ans/lib/awtextra/AbsoluteLayout
at primeraapp.PrimerForm.initComponents(PrimerForm.java:30)
at primeraapp.PrimerForm.<init>(PrimerForm.java:17)
at primeraapp.PrimerForm$3.run(PrimerForm.java:71)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)



I think may be I should use the -classpath option when running the
program from command prompt, but have no idea on what path to use.

May be there is a very simple way to get my application to work
outside the IDE, could anyone please tell me how?

Your help would be greatly appreciated.

- Jane
 
A

Andrew Thompson

I'm new to Java programming and need some help ...

People who are leaarning Java are better helped on a different group
I'm using NetBeans 4.0 beta2 to program Java applications.

Your problems begin right here. You should not be using a D'n'D
editor* to design your Java at this stage, since you have little
idea of what you are doing, like..

* said:
When I type:

java -jar PrimeraApp.jar

a) This is far too premature to be jarring your project
The results are:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/netbe
ans/lib/awtextra/AbsoluteLayout

b) Who put ans.lib.awtextra.AbsoluteLayout in yout code?
I can take a rough guess, but you need to know, and need
to write some Java without that.
 
S

Steve Sobol

Andrew said:
People who are leaarning Java are better helped on a different group



Your problems begin right here. You should not be using a D'n'D
editor* to design your Java at this stage, since you have little
idea of what you are doing, like..




a) This is far too premature to be jarring your project




b) Who put ans.lib.awtextra.AbsoluteLayout in yout code?
I can take a rough guess, but you need to know, and need
to write some Java without that.

org.netbeans.lib.awtextra.AbsoluteLayout is the class, and you specifically
have to put it in your classpath otherwise your compile will fail.
 
A

Andrew Thompson

org.netbeans.lib.awtextra.AbsoluteLayout is the class, and you specifically
have to put it in your classpath otherwise your compile will fail.

While that may technically be the case, I feel the OP
would be better served by ..

a) Learning the Sun layouts.
<http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html>

b) Following the advice in the first (c.l.j.help) and second
(set aside Netbeans for the moment) of the links you trimmed.
 
N

Nigel Wade

Jane said:
I'm new to Java programming and need some help ...

I'm using NetBeans 4.0 beta2 to program Java applications. I can
compile and run them without trouble inside the IDE, but I can't get
them to work outside the IDE. I am using Swing components on my forms.

After building the application, the IDE generates PrimerForm.class,
PrimerForm$1.class, PrimerForm$2.class, PrimerForm$3.class and
PrimeraApp.jar files (just one class in my first project).

I am trying to run the application outside the IDE. When I type:

java PrimerForm

The results are:

Exception in thread "main" java.lang.NoClassDefFoundError: PrimerForm
(wrong name: primeraapp/PrimerForm)

That looks like a package problem. Is PrimerForm in the primeraapp package
by any chance?

You should run java from the base directory of the package structure, not
from within a sub-package. You need to move up out of the primeraapp
directory and then run:

java primeraapp.PrimerForm
 
F

FISH

I'm new to Java programming and need some help ... [snipped...]

I am trying to run the application outside the IDE. When I type:

java PrimerForm

The results are:

Exception in thread "main" java.lang.NoClassDefFoundError: PrimerForm
(wrong nam
e: primeraapp/PrimerForm)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
[snipped...]

Is PrimerForm the fully qualified name of your application? If it
lives inside a package you should specify the package name too:

java packagename.ClassName

Ensure also that the 'root' directory where that package lives is on
the classpath. This is the directory which holds your package
directories, not the directory which holds the classes themselves.
If you built your packages into a directory called "/myprojects", such
that a class "mypackage.MyClass" would be compiled into a file called
"/myprojects/mypackage/MyClass.class", then your would put "/myprojects"
on the classpath, thus:

java -cp /myprojects mypackage.MyClass


When I type:

java -jar PrimeraApp.jar

The results are:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/netbe
ans/lib/awtextra/AbsoluteLayout
at primeraapp.PrimerForm.initComponents(PrimerForm.java:30)
at primeraapp.PrimerForm.<init>(PrimerForm.java:17)
[snipped...]

It is failing to find the class org.netbeans.lib.awtextra.AbsoluteLayout,
which one would assume from the name is supplied by Netbeans itself(?)

I think may be I should use the -classpath option when running the
program from command prompt, but have no idea on what path to use.

You need to find the Jar (or directory) which contains the missing
class, and make sure it is on your classpath.

May be there is a very simple way to get my application to work
outside the IDE, could anyone please tell me how?

Read the supplied Netbeans documentation/help. It may contains clues.

One of the nice things about learning a new language using an IDE
is you can appear to climb the learning curve much quicker. One of
the worst things is when you do eventually run into trouble, it can
become painfully apparent just how much shielding yourself from the
nitty-gritty of the development cycle has left you ill-prepared to
diagnose even the most basic of problems.


-FISH- ><>
 
D

deadelus

I'm new to Java programming and need some help ...

I'm using NetBeans 4.0 beta2 to program Java applications. I can
compile and run them without trouble inside the IDE, but I can't get
them to work outside the IDE. I am using Swing components on my forms.

After building the application, the IDE generates PrimerForm.class,
PrimerForm$1.class, PrimerForm$2.class, PrimerForm$3.class and
PrimeraApp.jar files (just one class in my first project).

I am trying to run the application outside the IDE. When I type:

java PrimerForm

The results are:

Exception in thread "main" java.lang.NoClassDefFoundError: PrimerForm
(wrong nam
e: primeraapp/PrimerForm)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

When I type:

java -jar PrimeraApp.jar

The results are:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/netbe
ans/lib/awtextra/AbsoluteLayout
at primeraapp.PrimerForm.initComponents(PrimerForm.java:30)
at primeraapp.PrimerForm.<init>(PrimerForm.java:17)
at primeraapp.PrimerForm$3.run(PrimerForm.java:71)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)



I think may be I should use the -classpath option when running the
program from command prompt, but have no idea on what path to use.

May be there is a very simple way to get my application to work
outside the IDE, could anyone please tell me how?

Your help would be greatly appreciated.

- Jane

You could make a bat file with the following:
D:\JBUILDER6\jdk1.3.1\bin\java
-Xbootclasspath/a:.;I:\WebGis\KlicBE\webgis_klic\activation.jar;I:\WebGis\KlicBE\webgis_klic\mail.jar;d:/Wilem/testBackend/web_klic;d:/Wilem/testBackend/web_klic/access;
-jar webgis_klic.jar

In this case a executable jar file will be started.
the /a:. takes care for searching in the current directory.
More information can be found on java.sun.com.

@Deadelus...
 
B

Brock Heinz

I'm new to Java programming and need some help ...

I'm using NetBeans 4.0 beta2 to program Java applications. I can
compile and run them without trouble inside the IDE, but I can't get
them to work outside the IDE. I am using Swing components on my forms.

Typically a command script will help you in this scenario. I've never
really used NetBeans, but I'm guessing there is somewhere that you can
determine the JARs in your project's classpath. Once that has been
determined, the rest is easy. Write a script that looks something
like the following (assuming you are in a windows environment and java
is in your OS path):

set JAR_HOME=D:\netbeans\project
set CLASSPATH=%JAR_HOME%\jar1;%JAR_HOME%\jar2;%JAR_HOME%\jar3;
java primeraapp.PrimerForm


Note: you can also set up your classpath directly in your java
command. To see more information on that key in the following (again,
assuming 'java' is in your PATH)

java -help

Hope this helps,
Brock
 
A

Andrew Thompson

...I've never
really used NetBeans, but I'm guessing there is somewhere that you can
determine the JARs in your project's classpath.

LOL. In the time since this thread has been dribbling along,
another poster popped up on c.l.j.help with Netbeans problems.
<http://groups.google.com/[email protected]>
(so fresh it is not on Google at time of posting)

I advised the poster to dump Netbeans*, and they have
...*since then* got their applet not just compiled and running,
but jar'd and signed as well.

* As I advised on this thread.

How are you doing, Jane?
 
J

Jane Sfelc

Andrew Thompson said:
LOL. In the time since this thread has been dribbling along,
another poster popped up on c.l.j.help with Netbeans problems.
<http://groups.google.com/[email protected]>
(so fresh it is not on Google at time of posting)

I advised the poster to dump Netbeans*, and they have
..*since then* got their applet not just compiled and running,
but jar'd and signed as well.

* As I advised on this thread.

How are you doing, Jane?

Thank you every one for your help ...

After some testing I finally got my app running outside the IDE. The
problem was that my main class primeraapp.PrimerForm used
org.netbeans.lib.awtextra.AbsoluteLayout class, and that class was not
found at runtime. The IDE did not pack that class with my project
files. After looking inside the jdk1.5.0 directory in my system I
found AbsoluteLayout.jar, decompressed it and extracted
AbsoluteLayout.class. The final solution was:

1. Made a directory to store all the classes on my project.
2. Put my application PrimerForm.class inside a \primeraapp directory.
3. Put AbsoluteLayout.class inside \org\netbeans\lib\awtextra
directory.
4. From the root directory, typed: java primeraapp.PrimerForm
5. The application is running!!!

I think NetBeans is not that bad. I followed your suggestions and got
some very nice books on Java programming.

Hope my experience helps other people too.

Bye,

- Jane
 
A

Andrew Thompson

..I think NetBeans is not that bad.

Don't get me wrong, I have nothing against powerful,
intuitive IDEs as such. It's just that people learning
Java should know how to compile, run and jar their projects
before they allow an IDE to 'do it for them'.

Why? Because the IDE's config. will become corrupted or lost,
and if you don't know how these things are done from the command
line, your chances of fixing the IDE are pretty slim.

Also, the layout you are using is a horrid one, and I can
say that without having ever used it. It (correct me if
I'm wrong) put's things *exactly* where you want them, right?

That might work fine on one OS, using one particular version
of Java, but move it anywhere else and you will discover that
the text of UI elements is a different size, or the default
borders and paddings have changed because of an updated PLAF.
The UI 'falls apart'.

In any case, glad you sorted this one. Think about what I've
said for the next problem that crops up.
 
M

Michael Borgwardt

Andrew said:
That might work fine on one OS, using one particular version
of Java,

and one particular language and one particular set of installed fonts.
 
R

Ravi

Totally agree with you Andrew. Alot of beginner Java users dive
straight into IDE's such as Netbeans etc. When it comes to problems
with compiling, deploying and so on, it would be useful for them to
know how to directly do this from a command line argument, or better
yet, consult the java specification documentation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top