This doesn't appear to be the usual CLASSPATH issue, but maybe something specific to cygwin.
The following illustrates the issue.
import net.jradius.packet.attribute.AttributeFactory;
public class Test{
static int x = 100;
}
When compiling the following error appears.
$ javac Test.java
Test.java:1: error: package net.jradius.packet.attribute does not exist
import net.jradius.packet.attribute.AttributeFactory;
^
1 error
The file jradius-core-1.1.4.jar is in the CLASSPATH.
When using the command line within Windows it works. Here is the classpath.
set CLASSPATH=c:\Temp\jradius-core-1.1.4.jar
When using cygwin it produces the error. Here is the classpath.
export CLASSPATH=/cygdrive/c/Temp/jradius-core-1.1.4.jar
The location is valid via cygwin as the following shows it is recognized.
ls $CLASSPATH
/cygdrive/c/Temp/jradius-core-1.1.4.jar
The same JDK is used for both scenarios.
Any idea why it may be failing via cygwin???
You are using JDK built for windows, so the environment is for windows.
That's being said, you should be provide windows-style path to javac.
cygpath is what you are looking for here.
Try:
javac Test.java -cp `cygpath.exe -w /cygdrive/c/Temp/jradius-core-1.1.4.jar`
cygpath -w means print in windows style.
Or just put the jar file in the same directory of the java file, and in cygwin:
javac Test.java -cp jradius-core-1.1.4.jar
Refer from this
Added the JAR files into the directory and changed the classpath to include '*' and that appears to have worked.
Related
My build.hxml file looks like this:
-main Main
-cp src
-js bin/index.js
I use js.Browser in Main class. When I try to build it with F8, FlashDevelop gives me "You cannot access the js package while targeting cross". And I actually see that it tries to run:
Running process: bla-bla-bla -target "js"
...
cmd: cmd /c haxe build.hxml
haxe -cp src -main Main
So it removes -js parameter from hxml and then fails the build. How to fix it?
In the project properties, choose "Custom Build" as compilation target.
The reason is that the hxml target uses a custom build command (Build tab) and when the Application compilation target is selected, FD will try to compile it a second time with an incorrect configuration. This is legitimately a bug in FD - raise an issue on Github?
I have compiled the java codes with
razrlele#OVO:~/workspace/javastudy/src$ javac Helloworld.java
and it turns out no errors or warnings
then I run the program with
razrlele#OVO:~/workspace/javastudy/src$ java Helloworld
it returns this
Error: Could not find or load main class Helloworld
I have to input like this
razrlele#OVO:~/workspace/javastudy/src$ java -cp ./ Helloworld
so that the program will run correctlly.
I am confused about why the "java" command doesn't work.
Here is my /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_11"
CLASSPATH=/usr/lib/jvm/jdk1.8.0_11
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_11
Java will attempt to use your classpath to locate the class files. Since your classpath is set to /usr/lib/jvm/jdk1.8.0_11, that's where it looks.
By overriding the classpath with -cp ./, you tell it to look in the current directory for its class files.
There are a number of ways to fix this, including changing your classpath environment variable to include . or other localised paths as needed. I tend to prefer just setting up an alias (in my .bashrc for example) so regular Java programs aren't affected, something like (from memory):
alias jhere="java -cp $CLASSPATH:."
then I can just use:
jhere HelloWorld
to test my snippets.
Because . isn't in your CLASSPATH, first
export CLASSPATH="/usr/lib/jvm/jdk1.8.0_11:."
then
javac Helloworld.java
java Helloworld
It's also possible to use -cp (which is short for -classpath) with java at the command line, if you run java -h you will see
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
Im learning to code Android in NDK on WINDOWS Eclipse.... been following a Tutorial Book by Sylvain Ratabouil. So im in Run | External Tools | External Tools Configurations…
creating a new program configuration.
Name: MyProject javah
Location : ${env_var:JAVA_HOME}\bin\javah.exe
Working directory: ${workspace_loc:/MyProject/bin}
The problem comes In arguments...
when i try
Arguments: –d ${workspace_loc:/MyProject/jni} com.myproject.MyActivity
as it says in the book
i get when i click run
Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: –d
when i try ${workspace_loc:/MyProject/jni} com.myproject.MyActivity}
i get
Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: C:\Paul\Workspace\MyProject\jni
UPDATE:
i put -classpath first and it's running but can not find the class file for com.myproject
after further research....
i did it.
i set arguments to
-d ${workspace_loc:/MyProject/jni} -classpath C:\Paul\android-sdk-windows\platforms\android-17\android.jar;${workspace_loc:/MyProject/bin/classes} com.myproject.MainActivity
I also spend some long time on this problem when working with the the mentioned book about Android NDK.
Please note the following:
The java classname is NOT written in { }, just write something like com.myproject.MyActivity
The -classpath parameter can receive several paths devided by semicolon.
In my case this parameters worked:
Location:
${env_var:JAVA_HOME}\bin\javah.exe
Working Directory:
${workspace_loc:/myproject/bin}
Arguments:
-d ${workspace_loc:/myproject/jni} -classpath ${workspace_loc:/myproject/bin/classes};"C:\Eclipse\sdk\platforms\android-18\android.jar" com.myproject.MyActivity
(BTW.: The correct Adroid.jar file is referenced inside the Eclipse project.)
Me also facing the same problem tonight, i found a less tedious way as following...
as "Location" set the javah from your system
as "Working directory" set the project's bin/classes directory (${workspace_loc:/HelloWorld/bin/classes})
as "Argument" set the jni folder as the output directory and point out the class on which you want to run the javah (-d "${workspace_loc:/HelloWorld/jni}" com.example.helloworld.MainActivity)
NB :: Dont forget the double qoute (") around the output in the third step ("${workspace_loc:/HelloWorld/jni}")
A full picture is also attached following
well in case ...
1-> Goto ( cd C:\Program Files\Java\jdk1.7.0_60\bin)
2-> C:\Program Files\Java\jdk1.7.0_60\bin>javah -jni -classpath
F:\Android_OpenGLES\FibonacciNative\bin\classes
-d F:\Android_OpenGLES\FibonacciNative\jni\ com.example.fibonaccinative.FibLib
without creating/using environment variable ...
Following I tried successfully
javah com.sense.kios.Calculation
Note: Include package name.
In case if javah not found as an command and you getting
The program 'javah' can be found in the following packages:
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>
use direct path of jdk path, in my case it's /usr/lib/jvm/jdk1.8.0/bin/javah.
YES THAT'S CORRECT
more abstract would be
-d ${workspace_loc:/MyProject/jni} -classpath ${env_var:ANDROID_SDK_HOME}\platforms\android-16\android.jar;${workspace_loc:/MyProject/bin/classes} com.myproject.MyActivity
There appears to be a Ant / jni.h problem (for my setup) with LibusbJava. I get the following error when setting up LibusbJava by running
ant linux
in CentOS 6.3 as root (quick and dirty test, thanks for those concerned about user level =0). I will redo with proper restrictions as shown on a libusbjava reference after reflection when first install works. LibusbJava, is a Java wrapper for the libusb library.
The output starts out like this:
[root#somebox LibusbJava]# ant linux -lib $JAVA_HOME/include -lib $JAVA_HOME/include/linux
Buildfile: build.xml
clean:
Build LibusbJava Test Linux:
Build LibusbJava Test:
[echo] Building Library for unit tests:
[exec] /.../libusbjava/trunk/LibusbJava/LibusbJava.cpp:27:17: error: jni.h: No such file or directory
[exec] /.../libusbjava/trunk/LibusbJava/LibusbJava.cpp:34:26: error: test/CuTest.h: No such file or directory
`...`
as it was not set on my system. It appears that jni.h is a header called by C++ code, which I had to add to the LibusbJava.cpp file. This is the new include, /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/include/jni.h. I then get an error with jni.h not being able to fine jni_md.h which is an include in jni.h #include "jni_md.h".
Clearly this is not the right approach, so perhaps I need a correct Ant reference, but I cannot seem to do it with a -lib switch. Besides, this just creates thousands of jni.h file errors during the Ant build attempt.
How can I fix this problem?
Notes: I've set$JAVA_HOME up like JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64 and javac and java work fine.
New discovery... after helpful questions which guided me, I am much closer to successful compilation.
When I install LibusbJava and manually install all the library references in build.xml there is still an error compiling the LibusbJava based on a memset error. I see memset patches for libusb that appeared in 2007 and it's unclear how to use or if they relate. Investigating... Hints, comments and questions welcome. My most sincere thanks for the help thus far.
[exec] /.../libu/libusbjava/trunk/LibusbJava/objects/Usb_Device.cpp: In function ‘void Usb_Device_disconnect(JNIEnv*)’:
[exec] /.../libu/libusbjava/trunk/LibusbJava/objects/Usb_Device.cpp:88: error: ‘memset’ was not declared in this scope
[antcall] Exiting /.../libu/libusbjava/trunk/LibusbJava/build.xml.
BUILD FAILED
but I find no referece to an include string.h or cstring. The header of Usb_Device.cpp mentions it is a C++ Stub for the java class of a java class ch.ntb.inf.libusbJava.Usb_Device. which only has this include #include "Usb_Device.h" which also does not appear to have a string include. Perhaps just insertion of#include`?
I'm on Windows 7, using javah in Cygwin 1.7.13. I'm currently attempting to generate the header file for a native C++ file for my Android project.
Run in the root of the project, the command I'm executing is:
walb#nought /cygdrive/c/Users/walb/stuff/work/workspace/SoundBites
$ javah -verbose -d jni/ -classpath bin/classes uk.co.biogen.SoundBites.activity.SoundBitesActivity
Which results in:
error: cannot access uk.co.biogen.SoundBites.activity.SoundBitesActivity
class file for uk.co.biogen.SoundBites.activity.SoundBitesActivity not found
javadoc: error - Class uk.co.biogen.SoundBites.activity.SoundBitesActivity not found.
[ Search Path: C:\Program Files\Java\jdk1.6.0_22\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\sun
rsasign.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\charsets.j
ar;C:\Program Files\Java\jdk1.6.0_22\jre\classes\bin/classes ]
Error: No classes were specified on the command line. Try -help.
Most of the topics I've read indicate that I've got the -classpath argument correct. The interesting bit of the error message is:
[ Search Path: C:\Program Files\Java\jdk1.6.0_22\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\sun
rsasign.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_22\jre\lib\charsets.j
ar;C:\Program Files\Java\jdk1.6.0_22\jre\classes\bin/classes ]
The last path in that list is C:\Program Files\Java\jdk1.6.0_22\jre\classes\bin/classes, which indicates javah is interpreting the argument completely wrong. The only thing I can think might help is some alternative way of calling javah, but adding its directory to PATH is the only means I can think of.
Just implemented what I wanted in native Android. It's easier to integrate and understand what's going on, at the expense of speed and actually doing what I wanted in the first place.
Does this work (adding a semi-colon before your path for the -classpath argument):
javah -verbose -d jni/ -classpath ;bin/classes uk.co.biogen.SoundBites.activity.SoundBitesActivity