• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Javac does not import

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am facing a surprising problem. I have 2 java class files. I write the import statement for second one in the first one. There is no package & these are in the same directory. I have compiled the second one. But when I try to compile the First one. Javac throws error at import statement like below :

D:\Clubs\oct\6>javac -d . ManojTest.java
ManojTest.java:1: '.' expected
import SessionBean;
^
1 error


My Java Files are as below :

import SessionBean;
public class ManojTest
{

public static void main(String args[])
{

}
}
//ManojTest.java

******************************
public class SessionBean
{

public static void main(String args[])
{

}
}
//SessionBean.java

I have compiled SessionBean.java successfully but when I try to compile ManojTest.java I get error mentioned above.

However this probelm comes when I use j2se 1.4.2.. but works in j2se 1.3.1..

Another way could be I use package structure.

But I can't do any of these, as I have to port my big project to j2se1.4.2.. from j2se1.3.1.. (Live project is running on Tomcat).

Problems is similar in Unix & Windows both.

Is this javac compiler issue or there is some setting which I can make.
I have already included . (dot) in PATH & CLASSPATH environment varibales.

Please help me out if there is any way around this, as i am stuck up in between

thank you

Manoj
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Manoj -

I think u can remove ur import SessionFile statement from the second file, as u said that u have .(dot) in ur classpath and then compile ur file.
 
Manoj Tyagi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ashish for the suggestion..

But issue is that I have to port existing project which has 100-150 jsp files having 1000 of import statements. That does not seems to be feasible.

I want to know whether this is compiler issue & whether I have any way around this my some simple setting or so as code/project is perfectly compiling & running with j2sdk1.3.1 & I just want ot take it to j2sdk1.4.2..

Please sugggest if any thing else i could do......

Thanks & waiting for some more help

Manoj
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might as well go ahead and put all classes involved with your JSP in packages - otherwise you face an endless stream of mystery malfunctions.
As written, SessionBean is in the default package which never has to be imported, instead the compiler depends on the "current directory" and the CLASSPATH.
JSP engines such as Tomcat pay NO ATTENTION to the current directory or the CLASSPATH.
Bill
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic