The import org.jdesktop cannot be resolved

V

vlenin66

I work on linux.
I have in /usr/local/netbeans-6.0/platform7/modules
the file org-jdesktop-layout.jar

When I try:
$ javac -classpath /usr/local/netbeans-6.0/platform7/modules/org-
jdesktop-layout.jar j*/*.java

it fails:
1. ERROR in javaapplication2/NewJFrame.java (at line 8)
import org.jdesktop.layout.*;
^^^^^^^^^^^^
The import org.jdesktop cannot be resolved
(javaapplication2/NewJFrame.java is a netbeans frame, and I can
compile it
from inside netbeans perfectly, but I can not compile it using javac
from command
line. That is the goal).

I also tried to copy /usr/local/netbeans-6.0/platform7/modules/org-
jdesktop-layout.jar
into /usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib and /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/jre/lib/ext,
that dod not help.

What can I do to get it resolved?

Thanks!
 
L

Lew

vlenin66 said:
I work on linux.
I have in /usr/local/netbeans-6.0/platform7/modules
the file org-jdesktop-layout.jar

When I try:
$ javac -classpath /usr/local/netbeans-6.0/platform7/modules/org-
jdesktop-layout.jar j*/*.java

it fails:
1. ERROR in javaapplication2/NewJFrame.java (at line 8)
import org.jdesktop.layout.*;
^^^^^^^^^^^^
The import org.jdesktop cannot be resolved
(javaapplication2/NewJFrame.java is a netbeans frame, and I can
compile it
from inside netbeans perfectly, but I can not compile it using javac
from command
line. That is the goal).

I also tried to copy /usr/local/netbeans-6.0/platform7/modules/org-
jdesktop-layout.jar
into /usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib and /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/jre/lib/ext,
that dod not help.

What can I do to get it resolved?

$ jar tf $NETBEANS_HOME/platform7/modules/org-jdesktop-layout.jar
META-INF/
META-INF/MANIFEST.MF
org/
org/netbeans/
org/netbeans/libs/
org/netbeans/libs/layoutext/
org/netbeans/libs/layoutext/Bundle.properties

No sign that org.jdesktop.layout is in there. Maybe if you read the
MANIFEST.MF you'll discover that the layout manager is actually in
$NETBEANS_HOME/platform7/modules/ext/swing-layout-1.0.3.jar.

It doesn't do much good to copy a JAR without the JARs on which it depends.
 
L

Lew

For God's sake, don't put your crap into the JVM lib/ directory, and avoid
like heck putting it into the extensions.

You should upgrade your Java. There was a security patch since that version -
I think update 11 is the first of the Java 5s to get it. How come you're not
using Java 6?
 
V

vlenin66

$ jar tf $NETBEANS_HOME/platform7/modules/org-jdesktop-layout.jar
META-INF/
META-INF/MANIFEST.MF
org/
org/netbeans/
org/netbeans/libs/
org/netbeans/libs/layoutext/
org/netbeans/libs/layoutext/Bundle.properties

No sign that org.jdesktop.layout is in there. Maybe if you read the
MANIFEST.MF you'll discover that the layout manager is actually in
$NETBEANS_HOME/platform7/modules/ext/swing-layout-1.0.3.jar.

It doesn't do much good to copy a JAR without the JARs on which it depends.

Lew, thanks for the reply.
It still does not work:
en@gepem:~/NetBeansProjects/JavaApplication2/src$ javac -classpath /
usr/local/netbeans-6.0/platform7/modules/ext/swing-layout-1.0.3.jar j*/
*.java
----------
1. ERROR in javaapplication2/NewJFrame.java (at line 8)
import org.jdesktop.layout.*;
^^^^^^^^^^^^
The import org.jdesktop cannot be resolved

swing-layout-1.0.3.jar shows org.jdesktop.layout using Ark.

Thanks!
 
V

vlenin66

For God's sake, don't put your crap into the JVM lib/ directory, and avoid
like heck putting it into the extensions.

For Mysql connection that was the solution: I put my crap into JVM,and
voila, mysql worked.
You should upgrade your Java. There was a security patch since that version -
I think update 11 is the first of the Java 5s to get it. How come you're not
using Java 6?
I use linstalled knoppix, and it delivers java 1.5. I'd like to get
this work with java 1.5.
I do not want to install anything new, since the given java program
works well with netbeans.
The goal is, to get it work from command line.

Thanks!
 
V

vlenin66

..

I found in the mean time, that Kaffe was also installed. If I use
originaljava/javac, I can compile. Now the problem looks: HelloWorld
works fine, gui compiles, but fails with class not found.

Here the details:

HelloWorld program
--------------------

compile:
-------
en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/javac -cp /usr/local/netbeans-6.0/
platform7/modules/ext/swing-layout-1.0.3.jar javaapplication2/
Main.java

Run
----
en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/java javaapplication2.Main
Hello Hattyú

Hello ClassNotFound with swing layout classpath:
-------------------------------------------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ java -cp /usr/local/
netbeans-6.0/platform7/modules/ext/swing-layout-1.0.3.jar
javaapplication2.Main
Exception in thread "main" java.lang.NoClassDefFoundError:
javaapplication2/Main

GUI compiles:
-------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/javac -cp /usr/local/netbeans-6.0/
platform7/modules/ext/swing-layout-1.0.3.jar javaapplication2/
NewJFrame.java

Gui ClassNoFound with swing layout:
-----------------------------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/java -cp /usr/local/netbeans-6.0/platform7/
modules/ext/swing-layout-1.0.3.jar javaapplication2.NewJFrame
Exception in thread "main" java.lang.NoClassDefFoundError:
javaapplication2/NewJFrame
en@gepem:~/NetBeansProjects/JavaApplication2/src$

Gui ClassNoFound with swing layout:
-----------------------------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/java javaapplication2.NewJFrame
Exception in thread "main" java.lang.NoClassDefFoundError: org/
jdesktop/layout/GroupLayout$Group


Thanks in advance!
 
V

vlenin66

Found the solution:
when I say:
java -cp /usr/local/netbeans-6.0/platform7/modules/ext/swing-
layout-1.0.3.jar:.:./javaapplication2 javaapplication2.NewJFrame

then gui works (also HelloWorld works like that).

Thanks for the help, Happy End. :)
 
L

Lew

For Mysql connection that was the solution: I put my crap into JVM,and
voila, mysql worked.

Actually, that was most definitely not "the solution" but a maintenance
nightmare a-borning. It was a workaround, and may have suppressed your
symptoms, but it was no more a cure than aspirin is a cure for the flu even
when it gets rid of the headache.

Putting custom JARs in the JVM itself is bad. Putting them in the extensions
directories is dangerous, and often bad unless the practitioner fully
understands the consequences. Neither is really ever necessary - extensions
directories exist so that you can, in effect, expand the Java language itself.
Normal library references are better managed by using the classpath.

In any event, you put the wrong JAR in there, so extensions, JVM lib/ or
classpath doesn't matter.

Please study the matter and learn why it's bad to put things in the JVM lib/
or extensions directories without full understanding.
 
L

Lew

vlenin66 said:
It still does not work:
en@gepem:~/NetBeansProjects/JavaApplication2/src$ javac -classpath /
usr/local/netbeans-6.0/platform7/modules/ext/swing-layout-1.0.3.jar j*/
*.java
----------
1. ERROR in javaapplication2/NewJFrame.java (at line 8)
import org.jdesktop.layout.*;
^^^^^^^^^^^^
The import org.jdesktop cannot be resolved

swing-layout-1.0.3.jar shows org.jdesktop.layout using Ark.

I'm going to assume that the line breaks in your posted command do not
correspond to whitespace in the actual command line.

It sure looks mysterious based on the information you have provided so far.

Would you post the top part of your javaapplication2/NewJFrame.java source,
from the top through the "class" declaration line?
 
L

Lew

vlenin66 said:
Hello ClassNotFound with swing layout classpath:
-------------------------------------------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ java -cp /usr/local/
netbeans-6.0/platform7/modules/ext/swing-layout-1.0.3.jar
javaapplication2.Main
Exception in thread "main" java.lang.NoClassDefFoundError:
javaapplication2/Main

You need to add "." to the classpath.
Gui ClassNoFound with swing layout:
-----------------------------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/java -cp /usr/local/netbeans-6.0/platform7/
modules/ext/swing-layout-1.0.3.jar javaapplication2.NewJFrame
Exception in thread "main" java.lang.NoClassDefFoundError:
javaapplication2/NewJFrame
en@gepem:~/NetBeansProjects/JavaApplication2/src$

You need to add "." to the classpath.
Gui ClassNoFound with swing layout:
-----------------------------------

en@gepem:~/NetBeansProjects/JavaApplication2/src$ /usr/lib/jvm/
java-1.5.0-sun-1.5.0.10/bin/java javaapplication2.NewJFrame
Exception in thread "main" java.lang.NoClassDefFoundError: org/
jdesktop/layout/GroupLayout$Group

You need to add the JAR and "." to the classpath.

Also, could you (at least temporarily) add the Java 'bin/' directory to your
PATH? All this line wrapping makes your stuff really hard to decipher.
 
L

Lew

vlenin66 said:
Found the solution:
when I say:
java -cp /usr/local/netbeans-6.0/platform7/modules/ext/swing-
layout-1.0.3.jar:.:./javaapplication2 javaapplication2.NewJFrame

then gui works (also HelloWorld works like that).

'./javaapplication2' (or more simply, just 'javaapplication2') should not be
part of the classpath, because it's part of the package structure.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top