Cannot find class in package when compiling with javac - classpath

I have the following structure in my directory :
PROJECT
- classes
tunnelvisionlabs
postgresql
PostgreSqlLexer.class
PostgreSqlLexerAtnSimulator.class
PostgreSqlLexerUtils.class
- lib
antlr-4-7.jar
- BasicTest.java
In BasicTest.java, i have these imports:
package com.tunnelvisionlabs.postgresql.test;
import com.tunnelvisionlabs.postgresql.PostgreSqlLexer;
import com.tunnelvisionlabs.postgresql.PostgreSqlLexerUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Token;
import org.junit.Assert;
import org.junit.Test;
I try to compile with the following command :
javac -cp .:./lib/* BasicTests.java
I get these errors :
BasicTests.java:28: error: cannot find symbol
import com.tunnelvisionlabs.postgresql.PostgreSqlLexer;
^
symbol: class PostgreSqlLexer
location: package com.tunnelvisionlabs.postgresql
BasicTests.java:29: error: cannot find symbol
import com.tunnelvisionlabs.postgresql.PostgreSqlLexerUtils;
^
symbol: class PostgreSqlLexerUtils
location: package com.tunnelvisionlabs.postgresql
In the PostgreSqlLexer and PostgreSqlLexerUtils classes, i have this package declared at the beginning:
package com.tunnelvisionlabs.postgresql;
What do i need to do for my program to find these classes ? I tried adding the classes directory in lib and using the same command as before, so that the classpath also contains the classes directory, but it doesn't change anything.

If I read your project structure correctly, the source folder where BasicTest.java sits is at the same level as the lib folder. If so, then you can using the following javac classpath:
javac -cp .:lib/* BasicTests.java
^^^ lib/ is already where you are calling this
Review the following reference answer for more information:
Including all the jars in a directory within the Java classpath

Related

How to import module up multiple levels from base?

I'm trying to call a module several levels up from pytest run directory. How do I import this module?
I've tried:
sys.path.insert(0, 'path/to/module')
import modulename
Here's the directory structure:
tools
common
modulename.py (contains class A)
functional_test (this is where I'm running pytest; tools/functional_test)
conftest.py
pytest.ini
tests
typea (this is tools/funtional_tests/tests/typea)
tests_typea1.py
Under tests_typea1.py, I want to import class A from modulename.py under tools/common.
Getting the following Errors:
ImportError
ModuleNotFoundError: No module named 'modulename'
Well, after having another person look over my code, I realized that I miss-spelled my the import . Ugh... Note to self: change font style and confirm spelling. :). The above sys.path.insert or sys.path.append with import <modulename> works.

import java classes into jsp project in eclipse

I have a jsp project and I am using eclipse. I want to import a couple of external java source code into Java Resources src. Is there a way to do it rather than create a couple of new classes and then copy and paste the code into it? Thank you.
If they're already in the expected package layout for source files, you can just File|Import from the Filesystem.
Actually nobody is getting what if one havn't define package ???
then define package in ur java code as :-
package MyPackage;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
public class NavBackend {
static boolean isNumeric(String str)
{
..............
..............
then in your jsp file you can write like :
<%#page import="MyPackage.NavBackend"%>

Issues running haxe application in osx terminal with createjs library

When running this command
haxe -main Main.hx
I'm getting this error
Main.hx:2: characters 7-33 : Type not found : createjs.easeljs.Container
Main.hx
package ;
import createjs.easeljs.Container;
import createjs.easeljs.Shape;
import createjs.easeljs.Stage;
import createjs.easeljs.Text;
import createjs.easeljs.Ticker;
import js.Browser;
import js.html.CanvasElement;
import js.html.Element;
I've included the javascript file for the createjs library and I also installed the library using the command
haxe install createjs
You have to include the createjs haxelib with the -lib argument during compilation:
haxe -main Main.hx -lib createjs

Importing library in Dart

I know that to import some library, which is located in some folder. Example hiearchy:
library1
folder1
library2
Then importing library2 would look like:
import 'folder1/library2';
But how can I import library1 from library2?
import '../library1';
or
import 'my_package:library1.dart';
when the file library1.dart is stored in my_package/lib/library1.dart and your package name in pubspec.yaml is my_package.
If the imported file is deeper down the path relative path import is fine, when it's higher up the absolute import path (package:...) should be preferred.
Only files stored somewhere in the the lib directory of your package can be imported using a package:... path.
You can try this
import '../library1.dart';

The import com.interwoven cannot be resolved

I am new to Teamsite and a not sure which jar file to use for resolving the issue that I get while trying to write a Java Datasource in Eclipse.
The list of imports I am using are:
import com.interwoven.datasource.MapDataSource;
import com.interwoven.datasource.core.DataSourceContext;
import com.interwoven.livesite.dom4j.Dom4jUtils;
import com.interwoven.serverutils100.InstalledLocations;
import com.interwoven.cssdk.filesys.CSVPath;
All these imports show the same error
The import com.interwoven cannot be resolved.
Can anyone please tell me which jar files should I add?