Can't find ports with javax.comm api - java

I am trying to install the javax.comm api on a machine (I already installed on another machine and it is working fine) but when I run the sample "BlackBox" application I get a message that says "No serial ports found!". I have followed the instructions and put win32com.dll in the bin directory of the jdk, comm.jar in the lib directory of the jdk, and javax.comm.properties in the lib directory of the jdk. I have also added the comm.jar file to the classpath since i am using a jdk and not jre. All this and I still can't get BlackBox to find any serial ports. Can anybody help me with this?

There's a jre directory in your JDK directory. Use <jdk>/jre/lib, not <jdk>/lib. Also, if you've added another copy of comm.jar, located elsewhere, explicitly to your classpath, take it out.
You might want to add a System.out.println(System.getProperty("java.home") statement to your code to make sure that you are placing things in the right directory; even when you are running <jdk>/bin/java, the java.home property should be <jdk>/jre.

It works fine on my Windows XP (32 bit) and jdk1.6.0_21 as follows:
1) Set the environment variables:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21
Path=...;C:\Program Files\Java\jdk1.6.0_21\bin;
2) Install three files:
C:\Program Files\Java\jre6\lib\comm.jar
C:\Program Files\Java\jre6\lib\javax.comm.properties
C:\Program Files\Java\jre6\bin\win32com.dll
3) Run from terminal as follows:
cd commapi\samples
java -classpath "C:\Program Files\Java\jre6\lib\comm.jar";BlackBox\BlackBox.jar BlackBox

Related

javac is not recognized as internal command [duplicate]

This question already has answers here:
javac is not recognized as an internal or external command in windows 7
(3 answers)
Closed 2 years ago.
My current system config is -
Netbeans 12.0
JDK 14.0.2
Windows 10 (64bit)
I have added the environmental variable in PATH manually i.e. C:\Program Files\Java\jdk-14.0.2\bin.
I tried adding using cmd as well. As well as adding the JAVA_HOME as a new variable with value as C:\Program Files\Java\jdk-14.0.2 .
I have used the set command to do this process i.e. set path = "%path%;"C:\Program Files\Java\jdk-14.0.2\bin". Also, I have used the same command without the set keyword.
Since javah command was deprecated for versions of jdk>8, I have tried to use javac -h command as well.
I have also tried to install JDK v. 8.0.2 instead of the current one.
Although there's no javah.exe file in the bin folder, there is however javac.exe file.
I have uninstalled and reinstalled JDK and Netbeans quite a few times.
I am currently working on JNI with Netbeans IDE and C/C++ plugin. (I have successfully installed Cygwin and necessary extension for the file to build. Although I don't know how they affect this problem, still I thought I should add this).
The command I wish to use with 'javah' is the one used for creating a C header from a Java class i.e. 'javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main'.
But due to this error, I have been stuck for a few days. Please do assist.
Following way you can set Path variable temporary(it can only be used in the same command line):
You should do it this way:(notice =)
set PATH=C:\Program Files\Java\jdk-14.0.2\bin
And if you set JAVA_HOME variable correctly you can do it this way:
set PATH="%JAVA_HOME%\bin"
For setting this permanently read this post :
https://javatutorial.net/set-java-home-windows-10
We should know the reason for this
Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.
However, when we install any third party tool/software then path variable is not updated accordingly.
When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be
C:\Program Files\Java\jdk1.8.0_161
Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be
C:\Program Files\Java\jre1.8.0_161
We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.
Solution
we need to update JDK or JRE version specific directory location into PATH Environment variable.
In this case use
set path=C:\Program Files\Java\jdk-14.0.2\bin to set JAVA_PATH

java 'jar' is not recognized as an internal or external command

I'm getting the following error when I try to run the 'jar' command in the command line on windows :
'jar' is not recognized as an internal or external command
The general solution seems to be that I need to add the jdk bin folder to the PATH in environment variables. I have already done this, I added the following to the path variable :
...; C:\Program Files\Java\jdk1.8.0_40\bin\;
Though I'm not sure if having the jdk reside in 'program files' instead of 'program files x86' affects this. I'm on 64 bit windows with 64 bit java.
Thanks
The path should only contain directories where the OS will look for executables. Strip the trailing "\jar.exe" to set your path as:
(old path variables here);C:\Program Files (x86)\Java\jdk1.7\bin
Thanks To : #stevevls
Try using this command:
java -version
If it doesn't work that means you failed to properly add path to jdk.
If it does work, try using:
java -jar
The jar command in command line is used in order to create a JAR file. For example:
jar cf jar-file input-file(s)
See more at: Oracle docs
If you want to run the existed JAR file you should use the java -jar command mentioned by #Aleksandr.
But in your case it looks like you don't have an access to the added directory in your path with JKD binaries so at the beginning try to execute mentioned java --version to check whether you have java in you classpath at all.
Please remember that on Windows you have to restart the console when you change the windows default path. You do not see the changes on the current console.
The x64 version of Java is installed on Program Files. The x86 version is installed on Program Files x86 by default.
Five steps to solve this problem:
check whether in your bin folder jar.exe is availbale or not
check for your environmental setting
download jar file from here http://originaldll.com/file/jar.exe/29248.html and keep in bin folder
now check for jar it will 100% work
keep any jar in your desktop and go to desktop path on cmd prompt and run the command jar xf filename.jar
Now see if it is working

Oracle SqlDeveloper JDK path

I have recently installed sqldeveloper but i'm getting the below warning window when I try to launch it. This is causing the sqldeveloper to run very very slow and it hangs frequently
I have tried editing the file sqldeveloper.cong as suggested in the window above but does not work
Original
SetJavaHome ../../jdk
Update 1
SetJavaHome C:\Program Files\Java\jdk1.7.0_60\bin\ and all other variations but still getting the above warning window
Update 2
SetJavaHome C:\Program Files (x86)\Java\jre7\bin and all other variations
Please suggest the correct way
The message seems to be out of date. In version 4 that setting exists in two files, and you need to change it in the other one, which is:
%APPDATA%\sqldeveloper\1.0.0.0.0\product.conf
Which you might need to expand to your actual APPDATA, which will be something like C:\Users\cprasad\AppData\Roaming. In that file you will see the SetJavaHome is currently going to be set to the path to your Java 1.8 location, so change that as you did in the sqldeveloper.conf:
SetJavaHome C:\Program Files\Java\jdk1.7.0_60\bin\
If the settig is blank (in both files, I think) then it should prompt you to pick the JDK location when you launch it, if you prefer.
another thing you could try is to rename your old jdk folder, lets say its:
C:\Program Files\Java\jdk1.7.0_04
change it to saomething like:
C:\Program Files\Java\xxxjdk1.7.0_04
Now, you should once again asked to set your jdk folder location on Oracle SqlDeveloper launch, and you can chose the right path.
Not the most elegant solution, but it worked for me.
Milos
In your SQL Developer Bin Folder find
\sqldeveloper\bin\sqldeveloper.conf
It should be
SetJavaHome \path\to\jdk
You said it was ../../jdk originally so you could ultimatey do 1 of two things:
SetJavaHome C:\Program Files\Java\jdk1.7.0_60
This is assuming that you have JDK 1.7.60 installed in that directory; you don't want to point it to the bin folder you want the whole JDK folder.
OR
The second thing you can do is find the jdk folder in the sqldeveloper folder for me its sqldeveloper\jdk and copy and paste the contents from C:\Program Files\Java\jdk1.7.0_60. You then have to revert your change to read
SetJavaHome ../../jdk
in your sqldeveloper.conf
If all else fails you can always redownload the sqldeveloper that already contains the jdk7 all zipped up and ready for you to run at will: Download SQL Developer The file I talk about is called Windows 64-bit - zip file includes the JDK 7
I cannot believe Oracle's documentation is SO LAME! In some documents it is misleading people to point to the JDK by specifying the path to the JDK root, e.g. on a Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/
Reviewing /Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
revealed the method they use to set up the path:
TMP_PATH=/usr/libexec/java_home -F -v 9
if [ -z "$TMP_PATH" ] ; then
TMP_PATH=/usr/libexec/java_home -F -v 1.8
if [ -z "$TMP_PATH" ] ; then
osascript -e 'tell app "System Events" to display dialog "SQL Developer requires a minimum of Java 8. \nJava 8 can be downloaded from:\n http://www.oracle.com/technetwork/java/javase/downloads/"'
exit 1
fi
fi
Executing this manually from Terminal:
/usr/libexec/java_home -F -v 1.8
Lists the path as:
/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
And this is what you need to specify as the value for
SetJavaHome /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
Thank you Oracle for wasting half a day on your "product" that does NOT even support your latest Java version, also released by you.
On Windows,Close all the SQL Developer windows. Then You need to completely delete the SQL Developer and sqldeveloper folders located in user/AppData/Roaming. Finally, run the program, you will be prompted for new JDK.
Note that AppData is a hidden folder.
For those who use Mac, edit this file:
/Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
Mine had:
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
and I changed it to 1.8 and it stopped complaining about java version.
if you use sqldeveloper 18.2.0
edit %APPDATA%\sqldeveloper\18.2.0\product.conf
jdk9, jdk10, and jdk11 are not supported
change back to jdk 8
for example
SetJavaHome C:\Program Files\ojdkbuild\java-1.8.0-openjdk-1.8.0.191-1

Adding self signed certificte to JRE keystore

A couple of months back I added a SSL cert in JRE's trustcacerts for avoiding not-a-valid-certificate issues.
There I imported the self signed certificate to the following file
"C:\Program Files\Java\jre6\lib\security\cacerts"
Question 1
But now when I am trying to access to this file it's not available and instead when I go to
"C:\Program Files\Java\jre6\lib"
I can find only one folder named ext and inside it a Zipped file named QTJava
Wonder what have happened to the files which were there under Java 6.
Question 2.
And also when I opened the Windows command Prompt in Admin mode and try to use keytool command in there it says
"C:\Program Files\Java\jre7\lib\security\cacerts"
'keytool' is not recognized as an internal or external command,
operable program or batch file.
I Would like to know if someone knows a way to get this done.
Q1: It seems fine on my system using the latest JRE, so I think your install is borked.
Q2: That's easy, add your JDK or JRE bin folder to the PATH environment variable. Normally something like set PATH="%PATH%;%JAVA_HOME%/bin" should do it (given that your JAVA_HOME variable points to your JDK or JRE installation folder).
Q1 : Installation may be corrupt
Q2 : Add your java/bin to your PATH variable.
PATH="%PATH%;%JAVA_HOME%/bin"
For this to work, You need to have JAVA_HOME variable set in your environment pointing to your JDK installation directory

Eclipse is not opening

I'm new to java and eclipse. I even saw this type of query on this website. But I have applied all those methods and it was also helpful. But when I try to open eclipse, it is not opening:
This is my path for java
C:\Program Files (x86)\Java\jre6
this is where my eclipse is
C:\Users\New folder\eclipse
But when I run the eclipse I'm getting an error
"A java rumtime environment(JRE) or java development kit(JDK) must be
available in order to run eclipse. No java virtual machine was found
after searching the following location: C:\Users\New
folder\eclipse\jre\bin\javaw.exe javaw.exe in your current path"
Please tell me the possible solution.
Thanks in advance!
If you have installed jdk then Eclipse won't have any issue to start. I think you just have installed JRE to run java programs. You need to install JDK.
To check whether you have installed JDK. Check Path C:\Program Files (x86)\Java. Your Java directory should contain directory jdk1.6.., If you don't have this directory there, search it at other places. If you did not find directory then you didn't install JDK.
Download JDK from here.
You should set JAVA_HOME and JRE_HOME variable. http://www.javawebonline.com/java-se-programming/beginners/java_home-jre_home-environment-variables/
And another suggestion is you should move your java home to another location and test your path to java such as
C:\Java\jre6
instead of
C:\Program Files (x86)\Java\jre6.
Go to C:\Users\New folder\eclipse
Open eclipse.ini file with text editor and add the javaw location there
( right after -vm part ) like so:
-vm
C:/Program Files/Java/jdk1.6.0_33/bin/javaw.exe <--- change to your path
-vmargs
Open the command prompt by pressing Windows+r, type cmd and press Enter.
Type javac and check the output.
If it gives all the options and usage, then you have configured the PATH vairables correctly, or else you have not set them up correctly.
Try it by checking the value at the command prompt.
NOTE
You need to open a new command prompt each time you change the environment variables.
If you have two Program Files folder in your C: drive
such as
C:\Program Files
C:\Program Files (x86)
then try to put your java inside
C:\Program Files
instead of C:\Program Files (x86)
It seems you are running 64 bit eclipse in 64 bit operating system. If you are running 64 bit eclipse then you need 64 bit JDK. Please install 64 bit JDK and run eclipse.

Categories

Resources