• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I put my class in a package and compile.

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem compiling my code below. Actually it compiles, however if I put the line Package Test;, and put it inside the subdirectory Test, I get an error saying package oracle does not exist.

I compile with "Javac SecTools.java". I cannot figure out why the compiler cannot find the oracle files, if I put the line Package Test; Any help is appreciated.

Package Test; <<----LINE GIVING ME PROBLEM.

import oracle.jdbc.pool.OracleDataSource;
import oracle.*;
import oracle.jdbc.driver.*;
import java.io.*;
import java.net.*;
import oracle.jdbc.driver.OracleDriver;

public class SecTools{
public SecTools() {...}
...
}
[ March 28, 2006: Message edited by: Fritz Largosa ]
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try Javac Test/SecTools.java

You must be one level above Test. If Test is in C:/programs/Test/, then the command prompt should say: C:/programs>

Also make sure that SecTools(and any other class/interface belonging to the Test package) is in a folder named Test.
[ March 28, 2006: Message edited by: Rusty Shackleford ]
 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I compile with Javac Test/SecTools.java I still get the error message

----------------------------------------------------

Test/SecTools.java:14: Package Oracle does not exist
Import oracle.*;
^
---------------------------------------------------

Before I had the same problem so I added the classpath c:\oracle\ojdbc.jar to my windows environment. SecTools.java compiled and run.
This is what I type.

C:\Prog1> Javac SecTools.java

Now when I want to put SecTools.java in a a Subdirectory and added Package Test; it does not seem to find my oracle files again.

C:\Prog1> Javac Test/SecTools.java
Compile Error!!!
----------------------------------------------------

Test/SecTools.java:14: Package Oracle does not exist
Import oracle.*;
^
---------------------------------------------------
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to your post, the original error was Package Test; <<----LINE GIVING ME PROBLEM.

Now the error message is:

Test/SecTools.java:14: Package Oracle does not exist
Import oracle.*;

Here is a hint: Java is case sensitive, including keywords.
[ March 28, 2006: Message edited by: Rusty Shackleford ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this tutorial helps at this point on your Java path. Let me know if it could be better. Thanks!!
 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Awesome tutorial, it helps!
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try compiling using this
javac -d . FileName.java

Regards
Simon
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Fritz Largosa:


Package Test; <<----LINE GIVING ME PROBLEM.



i could note that package Test; has been written as Package Test; and i think the 'P' should be 'p'.. so i think this might be the prob.. i am sure that it is a syntax error.. but i am not sure if that is the only error which u encounter.
 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys, it works now.
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic