3

This is my first post so please don't bite my head off!

I have found this: Java - How to import external packages?

and this: how to include libraries in java without using an IDE

but I'm still lost!

I have downloaded the file swingx-1.6.zip to my ~/Downloads folder (ubuntu) then unzipped it so I now have ~/Downloads/swingx-1.6 In this folder is swingx-1.6.jar which appears to have the class I want (JXPanel)

Then I ran this in a terminal: javac -classpath :~/Downloads/swingx-1.6/swingx-1.6.jar Panels.java were Panels.java is the class file which is (or will soon be) dependent on JXPanel.

I'm getting compile errors though!

Panels.java:6: package org.jdesktop.swingx does not exist
import org.jdesktop.swingx.JXPanel;
                      ^
1 error

My question is: Have I included the right files in the -classpath command? and Have I used the right import command?...

sorry for being such a noob, I really don't want to migrate to an IDE. I was just getting the hang of where I am now lol thanks in advance for your help.

Community
  • 1
  • 1
d.j.yotta
  • 532
  • 2
  • 12
  • Welcome to SO :) Can't answer your question immediately, but I had to chime in and recommend using an IDE...Java development is a hell of a lot easier with an environment. And Eclipse is free! – Ben Jul 10 '12 at 06:00

2 Answers2

1

Your import seems to be correct. I suspect your issue is the ':' at the beginning. ':' only needed as a separator, and having it at the start of the path may be confusing the compiler. Try it without the ':'.

To be honest if you are learning java an IDE will make that process easier.

Luke Cartner
  • 306
  • 1
  • 4
1

I think that you need to remove the ':' and also to use the full path, not ~/, because some software does not resolve it.

Stefania
  • 641
  • 1
  • 12
  • 34
  • Thanks! It wasn't the ':' (lost the default java packages when I removed that) but it was the '~/'. Appears to be working now. – d.j.yotta Aug 12 '12 at 04:28