aspose file tools*
The moose likes Beginning Java and the fly likes Class compilation question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class compilation question" Watch "Class compilation question" New topic
Author

Class compilation question

RobT
Greenhorn

Joined: Nov 30, 2000
Posts: 7
Thanks for the help on my previous posting.
Now I have another question. I have developed a more substatial program that uses another one of the packages. The code for the program is as follows:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.sql.*;
import com.bruceeckel.swing.*;
public class CopsLookup extends JApplet {
String dbUrl = "jdbc racle:thin:@192.1.16.126:1521:dev";
String user = "dba";
String password = "dba";
Statement s;
JTextField searchFor = new JTextField(20);
JLabel completion =
new JLabel(" ");
JTextArea results = new JTextArea(40, 20);
public void init() {
searchFor.getDocument().addDocumentListener(
new SearchL());
JPanel p = new JPanel();
p.add(new Label("Sequence Number to search for:"));
p.add(searchFor);
p.add(completion);
Container cp = getContentPane();
cp.add(p, BorderLayout.NORTH);
cp.add(results, BorderLayout.CENTER);
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection c = DriverManager.getConnection(
dbUrl, user, password);
s = c.createStatement();
} catch(Exception e) {
results.setText(e.toString());
}
}
class SearchL implements DocumentListener {
public void changedUpdate(DocumentEvent e){}
public void insertUpdate(DocumentEvent e){
textValueChanged();
}
public void removeUpdate(DocumentEvent e){
textValueChanged();
}
}
public void textValueChanged() {
ResultSet r;
if(searchFor.getText().length() == 0) {
completion.setText("");
results.setText("");
return;
}
try {
r = s.executeQuery(
"SELECT APP_NAME, " +
" LOG_TEXT_DESC, " +
" LOG_TEXT_MSG " +
"FROM LOGS " +
" WHERE LOG_SEQ_NBR ='" +
searchFor.getText()) ;
} catch(Exception e) {
results.setText(
searchFor.getText() + "\n");
results.append(e.toString());
return;
}
results.setText("");
try {
while(r.next()) {
results.append(
r.getString("App Name") + ", "
+ r.getString("Description") +
": " + r.getString("Message") + "\n");
}
} catch(Exception e) {
results.setText(e.toString());
}
}
public static void main(String[] args) {
Console.run(new CopsLookup(), 500, 200);
}
} ///:~
I use the following command line option:
D:\devsoft\jdk1.3\projects\OracleConnTest>javac -g -verbose -classpath d:\devsoft\jdk1.3\projects;d:
\devsoft\jdk1.3\projects\com\bruceeckel\swing;d:\orant\jdbc\lib\classes12.zip CopsLookup.java
I get the following error(s):
[parsing started CopsLookup.java]
[parsing completed 180ms]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JApplet.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/applet/Applet.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Panel.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Container.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Component.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/Object.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/image/ImageObserver.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/MenuContainer.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/io/Serializable.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/accessibility/Accessible.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/RootPaneContainer.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/String.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/sql/Statement.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JTextField.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JLabel.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JTextArea.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/event/DocumentListener.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/util/EventListener.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/event/DocumentEvent.class)]
[checking CopsLookup]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/text/JTextComponent.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JComponent.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/Icon.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/Comparable.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/text/Document.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JPanel.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Label.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/PopupMenu.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/BorderLayout.class)]
[loading d:\orant\jdbc\lib\classes12.zip(oracle/jdbc/driver/OracleDriver.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/sql/DriverManager.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/sql/Driver.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/sql/Connection.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/util/Properties.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/Exception.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/Throwable.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/sql/ResultSet.class)]
[loading d:\devsoft\jdk1.3\projects\com\bruceeckel\swing\Console.class]
CopsLookup.java:150: cannot access Console
bad class file: d:\devsoft\jdk1.3\projects\com\bruceeckel\swing\Console.class
class file contains wrong class: com.bruceeckel.swing.Console
Please remove or make sure it appears in the correct subdirectory of the classpath.
Console.run(new CopsLookup(), 500, 200);
^
[total 1332ms]
1 error
I compiled that class using the following command line option:
D:\devsoft\jdk1.3\projects\com\bruceeckel\swing>javac -g -verbose -classpath d:\devsoft\jdk1.3\proje
cts d:\devsoft\jdk1.3\projects\com\bruceeckel\swing\Console.java
The output from the compilation is as follows:
[parsing started d:\devsoft\jdk1.3\projects\com\bruceeckel\swing\Console.java]
[parsing completed 190ms]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/Object.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/String.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JFrame.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JApplet.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JPanel.class)]
[checking com.bruceeckel.swing.Console]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/Class.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/event/WindowAdapter.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/event/WindowListener.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/util/EventListener.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/event/WindowEvent.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/lang/System.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Frame.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Window.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Container.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Component.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/applet/Applet.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/Panel.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/GraphicsConfiguration.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(java/awt/PopupMenu.class)]
[loading D:\devsoft\jdk1.3\jre\lib\rt.jar(javax/swing/JComponent.class)]
[wrote d:\devsoft\jdk1.3\projects\com\bruceeckel\swing\Console$1.class]
[wrote d:\devsoft\jdk1.3\projects\com\bruceeckel\swing\Console.class]
[total 1242ms]
And finally the directory contains the following:
D:\devsoft\jdk1.3\projects\com\bruceeckel\swing>dir
Volume in drive D has no label.
Volume Serial Number is FCA8-8142
Directory of D:\devsoft\jdk1.3\projects\com\bruceeckel\swing
07/05/00 02:17p <DIR> .
07/05/00 02:17p <DIR> ..
11/30/00 02:07p 544 Console$1.class
11/30/00 02:07p 1,968 Console.class
04/24/00 04:32a 1,680 Console.java
04/24/00 04:33a 423 makefile
6 File(s) 4,615 bytes
8,555,216,896 bytes free
It appears that the class file is no good. Should I have compiled it for a specific version? I am using the jdk1.3. It seems like the class compiled okay. Am I missing something?
Mucho Grande Gracias in advance!!!
Rob Thompson
work email: robert.thompson2@firstunion.com
home email: rthom40065@aol.com
MESSAGE FROM ANGELA - FORUM MODERATOR.
YOU MAY NOTICE THAT I HAVE EDITED THIS MESSAGE. I HAVN'T CHANGED THE MESSAGE AT ALL JUST DISABLED SMILIES SINCE SOME OF THE CODE ACCIDENTLY PRODUCED THEM.

[This message has been edited by Angela Poynton (edited November 30, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Rob,
Dumb question, but your class file Console contains a package statement at the top? Something like this:
<PRE>
package com.bruceeckel.swing;
.
.
.
</PRE>
This has to be before any import statements in your class file (but it can be after comments) or else your class will be in the default package.
RobT
Greenhorn

Joined: Nov 30, 2000
Posts: 7
Thanks. I added . for the current path in the classpath variable and it compiled fine.
Rob Thompson
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Please note that The Java Ranch has a naming policy, described here and "RobT" is not a valid name. Please choose one which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Class compilation question