Current Position:Home > Error while compiling java file

Error while compiling java file

Update:10-11Source: network consolidation
Advertisement
Hi, im newby in java,
i was trying to compile java files, and after that i will use it in JSP as javabean.
I have 2 files already, the first file is a connection code, and its compiled successfully, it looks like this
i named this as ConnectionBean.java
package my_package;
import java.sql.*;
public class ConnectionBean {
     private Connection con;
     private static final String driver = "org.postgresql.Driver";
     private static final String url = "jdbc:postgresql://localhost:5432/PSQLDS";
     private static final String username = "postgres";
     private static final String password = "mypassword";
     public ConnectionBean() {
     public Connection logOn() {
          try {
               Class.forName(driver); con = DriverManager.getConnection(url, username, password); }
          catch(ClassNotFoundException e) {
               System.err.println("ConnectionBean: driver unavailable..."); con = null; }
          catch (SQLException e) {
               System.err.println("ConnectionBean: driver not loaded..."); con = null; }
          return con;
     public void logOff() {
          try {
               con.close(); }
          catch (Exception e) {
               e.printStackTrace(); }
as you can see above im using "package", and yes i have manage to put all my java files within the correct path (ROOT\WEB-INF\classes\my_package)
And also, i have test this class as javabean on JSP file and it works.
There for i continue to create the second java file, as a purpose to create a back engine for JSP. I use the same package as ConnectionBean.java, it looks like this
i named this as ListPageEngine.java
package my_package;
import java.beans.*;
import java.sql.*;
public class ListPageEngine {
     public static void main(String[] args) {
          ConnectionBean conBean = new ConnectionBean();}
on compiling process using command "javac ListPageEngine.java", i get this error message
ListPageEngine.java:11: cannot find symbol
symbol : class ConnectionBean
location: class my_package.ListPageEngine
ConnectionBean conBean = new ConnectionBean();}
^
ListPageEngine.java:11: cannot find symbol
symbol : class ConnectionBean
location: class my_package.ListPageEngine
ConnectionBean conBean = new ConnectionBean();}
^
2 errors
I think, i am pretty much sure that all my configuration (wheater its Apache TomCat, Environment Variable or PostgreSQL server) was good, as a prove, i was able to use ConnectionBean.class in my JSP file.
I susspect the problem is related with "package", seems i cannot use ConnectionBean class within ListPageEngine class when i use package.
For another information, i didn't install such thing as J2EE, i only install JDK 1.5, i also guess this might be the cause.
Right now im all stuck, i try to find thread which might be related with my problem but i failed to find it, most of them get the same answer by UncleSAM which are
Try the following forum (about JSP technology)
http://forum.java.sun.com/forum.jspa?forumID=45
JavaBeans spec contains nothing about JSP, but JSP spec describes using of beans.
i hope my question is clear so anyone who might have experience or clue with this problem might be able to help me.
Thanks before

The Best Answer

Advertisement
finally folks, i found answer to my own problem hehehehe..
the problem is on the compiling command (javac ... my_file.java), i found that i need to add some parameter on the command to make it works.
This problem solved.
  • Error while compiling java file Update:10-11

    Hi, im newby in java, i was trying to compile java files, and after that i will use it in JSP as javabean. I have 2 files already, the first file is a connection code, and its compiled successfully, it looks like this i named this as ConnectionBean.j

  • Error while compiling java file using J2SE 1.5.0 Update:10-11

    Dear Sir, I'm getting the following error while compiling the java file.The code is also given. package test; public class TestRowSet { public TestRowSet() { "TestRowSet.java": cannot access java.lang.Object,bad class file: D:\Program Files\Java

  • Problem compiling java file to access web service! newbie troubles ! Update:10-11

    I am new to web services and this is my first program... I am compiling java file which has import statement like: import org.apache.soap.util.xml.*; import org.apache.soap.*; import org.apache.soap.rpc.*; It says ----- package org.apache.soap.util.x

  • Compiling java files in DOS window Update:10-11

    Hi, I have been writin a small Client Server Application. I am attempting to use java packages in order to put certain class files into particular directories, and then import the packages when needed. So far, i have started my 1st attempt at a very

  • Location of compiled java files Update:11-30

    Where are the compiled java files for jsps? Sometimes I get jsp errors in the log files like: D:\jsrv\my\WEB-INF\_tmp_war_myserver_myserver_my\jsp_servlet\_mypage\_cancelmembership.java:105: ')' expected However, the _cancelmembership.java file does

  • Creating a .bat file to compile .java files Update:11-30

    Hi, I am trying to create a .bat file to compile java files. I have created the .bat in the same folder as teh .java file I am trying to compile. I know the path is set to the proper folder to find the compiler, but I keep getting an error saying the

  • Cannot compile java file after .. Update:11-30

    i installed java sdk 1.4 uninstalled java 1.2 & java 1.3.1 --after that i was not able to compile or run java file reinstalled java 1.3.1 and 1.2 --now able to run previously compiled java file --cannot compile a new java file any helpIt would be hel

  • How to check the JDK version of a compiled java file Update:10-11

    can anybody tell me how to check the JDK version of a compiled java file ? Edited by: gbhatia8 on Sep 9, 2010 7:04 AMThe major/minor version of the class file is the way to go. Also, it's not necessary to write a separate program to get to those. jav

  • Compiling java file in 11i Update:11-30

    I need to compile java file in CRM 11i .1003984 wrote: I need to compile java file in CRM 11i .Please see (HOW TO COMPILE JAVA FILES IN CRM APPLICATIONS [ID 468434.1]). Thanks, HusseinRead other 2 answers

  • Running a compiled java file Update:11-30

    Question: if a pc doesn't have the jre, how can it launch a compiled java file? For example, i create a program that calculates the expenses of a factory, i create the gui and i compile the file. Then i distribute my program. If a factory doesn't hav