javac reports "package does not exist" even though classpath is set - package

I have a file Test.java (stripped down for debugging):
import com.github.tkutche1.jgrade.Grade;
I try compiling it with this command line and get an error:
# javac -cp lib/com/github/tkutche1/jgrade/Grade.class:. Test.java
Test.java:1: error: package com.github.tkutche1.jgrade does not exist
import com.github.tkutche1.jgrade.Grade;
^
1 error
The package does exist, as shown:
# javap lib/com/github/tkutche1/jgrade/Grade.class
Compiled from "Grade.java"
public interface com.github.tkutche1.jgrade.Grade extends java.lang.annotation.Annotation {
}
Here's what happens with the verbose command line option [with added line breaks]:
# javac -verbose -cp lib/com/github/tkutche1/jgrade/Grade.class:. Test.java
[parsing started RegularFileObject[Test.java]]
[parsing completed 15ms]
[search path for source files: lib/com/github/tkutche1/jgrade/Grade.class,.]
[search path for class files: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/resources.jar,
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/sunrsasign.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jsse.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar,
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/charsets.jar, /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfr.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/classes,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/nashorn.jar,
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jaccess.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunpkcs11.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunjce_provider.jar,
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/localedata.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/icedtea-sound.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/dnsns.jar,
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/zipfs.jar,/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/cldrdata.jar, /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunec.jar,
lib/com/github/tkutche1/jgrade/Grade.class,.]
Test.java:2: error: package com.github.tkutche1.jgrade does not exist
import com.github.tkutche1.jgrade.Grade;
^
[total 111ms]
1 error
I am using javac 1.8.0_352 on Ubuntu. (I am trying to create a Gradescope autograder.)
I have read the answers to many similar questions, which say to include the .class file (or .jar file) in the classpath, which I have done. None of the questions have the output of javap showing that the package exists in the specified class.
What am I doing wrong?

The valid entries on the Java classpath are:
Directories containing compiled package trees ... whose names match the package name structure
Individual JAR files
JAR file wildcards
Entries that are none of the above will be silently ignored.
You have put an individual .class file on the classpath. It will be ignored.
Assuming that "lib" is a directory that contains "com/github/tkutche1/jgrade/Grade.class", your classpath should be:
$ javac -cp lib:. ....

Related

Codelite Clang Error: No Such File or Directory #./build-Debug

I have never used Codelite and am attempting to use it as apart of a requirement for "C Programming for Beginners" course on UDEMY.
I am using a Macbook PRO OS version 10.14.5 and Codelite version 14.0.0.
I have created a workspace called SampleApp and within lies a project called Sample with a src file and a main.c file.
The main. c file contains the following code:
#include <stdio.h>
int main()
{
printf("Hello, my name is Link\n");
return 0;
}
When I build the code I get the following output:
/bin/sh -c '/usr/bin/make -j8 -e -f Makefile'
====0 errors, 0 warnings====
Working directory is set to: /Users/link/Desktop/c_code/build-Debug/lib
Executing: open -n -a Terminal /tmp/codelite-exec.sh
Program exited
Unfortunately though, when my terminal pops up I get the following error message:
22:37:07-link#links-MacBook-Pro:~$ /tmp/codelite-exec.sh ; exit;
/tmp/codelite-exec.sh: line 3: cd: /Users/link/Desktop/c_code/build-Debug/lib: No such file or directory
Hit any key to continue...
I am unsure of how to debug this or get this program to run as it appears the target and or the executing directory is not set properly. Kindly advise, thank you.
** UPDATE **
There is no lib folder within /Users/link/Desktop/c_code/build-Debug/lib .. perhaps that's why the code in /tmp/codelite-exec.sh is not working.. Below shows /tmp/codelite-exec.sh - line 2 attempts to change directories to the lib folder and execute the Sample workspace but the lib file doesn't exist..
#!/bin/bash
command="/Users/link/Desktop/c_code/build-Debug/bin/Sample"
cd /Users/link/Desktop/c_code/build-Debug/lib && ${command}
echo Hit any key to continue...```
I've just run into the same problem trying to build a simple wxWidgets HelloWorld with CodeLite before I do anything serious with it. It turns out that this is caused by a default project setting. Open the settings (by right-clicking on your project and selecting settings at the bottom, in case you haven't found this yet). In the General page, find the Execution group and look for Working Directory. It defaults to "$(WorkspacePath)/build-$(WorkspaceConfiguration)/lib", which is pretty silly since that won't be created by default. I changed "/lib" to "/bin" and that error went away.

Python script to fetch an executable file from local repository git

I have an access to the local repository (git) of my company with this url -> "gitolite#10.10.10.55:/Intel/BareRepos/lteue.git" and my python script need to execute any file (.c & .h files) of this project and create a binary. After which the script has to run this binary file.
The code which I have wrote is:
import os
os.system("git clone gitolite#10.10.10.55:/Intel/BareRepos/lteue.git")
os.system("cd /home/saicharan/Documents/lteue")
os.system("gcc somefile.c")
os.system("./a.out")
I am getting the error like this
gcc: error: helloworld.c: No such file or directory
gcc: fatal error:no input files compilation terminated.
sh: ./a.out: No such file or directory
Please help me out with this.
Fortunately I got the solution for this:
os.system("git clone gitolite#10.10.10.55:/Intel/BareRepos/lteue.git")
os.chdir("path/to/file")
os.system("gcc path/to/file/somefile.c")
os.chdir("path/to/file")
os.system("./somefile.out")
and its working fine.!
You can make it even more simpler.
import os
os.system("git clone gitolite#10.10.10.55:/Intel/BareRepos/lteue.git")
os.chdir("path/to/file")
os.system("gcc path/to/file/somefile.c && ./somefile.out")
It Works.!

Accessing libnetlink.h

I'm trying to access some member variables within libnetlink.h, but when I #include in my source and compile with "gcc source.c -o binary", I get a "fatal error: libnetlink.h: No such file or directory" error.
I'm on Ubuntu 16.04 and I've already installed libnl-3-dev via apt-get install.
You need to put the correct path that must be seen from your source file.
this can be done by either:
1: Full path of the file 'libnetlink.h' like this (for example in linux):
/home/username/Desktop/folder1/libnetlink.h
2: Relative path of the file, corresponding to where your source file exist:
suppose your source file exist on 'Desktop', and your libnetlink.h exist in sub folder of Desktop folders called 'folder1', then the path will:
folder1/libnetlink.h
I guess the following command may help.
apt-get iproute-dev
I am using Fedora Core 26, after installing iproute-dev, the same problem is solved.

Littlemonkey QRcode scanner library patch issue while generating cn1lib library

I downloaded QRScanner project from https://github.com/littlemonkeyltd/QRScanner
and replace "codename1.arg.android.xapplication=" line in codenameone_library_appended.properties file. While building the library, it gives following error.
E:\QRScanner-master\src\org\littlemonkey\qrscanner\QRScanner.java:27Stubbing
Class: E:\QRScanner-master\build\stubs\org/littlemonkey/qrscanner/NativeScanner.java
: error: package com.codename1.ext.codescan does not exist
6 warnings
import com.codename1.ext.codescan.CodeScanner;
E:\QRScanner-master\src\org\littlemonkey\qrscanner\QRScanner.java:28: error: package com.codename1.ext.codescan does not exist
import com.codename1.ext.codescan.ScanResult;
Update 1: I have added the cn1-codescan.cn1lib dependencies but same problem as above exists...
-Unzipped cn1-codescan.cn1lib and kept main.zip inside lib folder
-changes in build.xml
<target name="-pre-compile">
<echo>Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
code size and wider device support</echo>
<mkdir dir="build/tmp"/>
<javac destdir="build/tmp"
source="1.5"
target="1.5"
bootclasspath="lib/CLDC11.jar"
classpath="lib/main.zip:${javac.classpath}:${build.classes.dir}">
<src path="${src.dir}"/>
</javac>
</target>
nbproject/project.properties file:
javac.classpath=\
${file.reference.CLDC11.jar}:\
${file.reference.CodenameOne.jar}:\
${file.reference.CodenameOne_SRC.zip}:\
${file.reference.QRScanner-override}:\
${file.reference.main.zip}
file.reference.main.zip=lib/main.zip
# Space-separated list of extra javac options
You can view the project here to see if I had done anything wrong:
https://drive.google.com/open?id=0B8ATnICIY2S8VzN0cGpwUTJLZTg
Thankyou
Fork and download CodeScanner from here and include the relevant package in your project.

PC-Lint error : Error 307: Can't open indirect file 'gcc-include-path.lnt'

I am trying to use PC-Lint on windows for exercising static code analysis on C files. I installed the software and ran the configuration setup for gcc compiler where I got the following files in the config directory:
co-gcc.h, co-gcc.lnt, env-ecl-console.lnt, filea.cpp, fileb.cpp, LIN.BAT,
lset.bat, options.lnt, std.lnt, std_a.lnt
However when I try to run the test sample by typing >lin filea fileb from the config directory, I get the following error:
co-gcc.lnt 37 Error 307: Can't open indirect file 'gcc-include-path.lnt'
How do we get the gcc-include-path.lnt file?
Error got solved by creating lint_cmac.h, lint_cppmac.h, gcc-include-path.lnt, and size-options.lnt files using the makefile co-gcc.mak located in PC-lint9.00h\lnt folder.

Resources