how can I check the compiler and runtime in netbeans? - java

in one of my questions ,somebody said that I have to make sure that I'm not using compiler 1.6 and 1.5 runtime when i want to execute or debug my program,but I don't know how can i check compiler and runtime in NetBeans ,I am beginner with NetBeans.
my question was:
**I debug my project and the result was :
debug: Have no FileObject for C:\Program Files\Java\jdk1.6.0_02\jre\lib\sunrsasign.jar
Have no FileObject for C:\Program Files\Java\jdk1.6.0_02\jre\classes**
what should i do?
and he answers : you have to make sure that you are not using compiler 1.6 and 1.5 runtime when you want to execute or debug your program

Here's what I use to find out everything about my building environment (never felt too warm with Eclipse):
import static java.lang.System.out;
public class Zeug {
static String[] opts = new String[] { "java.version", "java.vendor",
"java.vendor.url", "java.home", "java.vm.specification.version",
"java.vm.specification.vendor", "java.vm.specification.name",
"java.vm.version", "java.vm.vendor", "java.vm.name",
"java.specification.version", "java.specification.vendor",
"java.specification.name", "java.class.version", "java.class.path",
"java.library.path", "java.io.tmpdir", "java.compiler",
"java.ext.dirs", "os.name", "os.arch", "os.version",
"file.separator", "path.separator", "line.separator", "user.name",
"user.home", "user.dir" };
public static void main(String[] args) {
for(String o : opts) {
out.println(o + ": " + System.getProperty(o));
}
}
}

Go to Tools-->Java Platform and you should see the JDK you are using listed. I am using java-6-sun-1.6.0.16 which does indeed have the jar file you need.
Download the latest JDK from Sun. Go to Tools-->Java Platform and click Add Platform. Navigate to where you installed the latest JDK, name it something meaningful like JDK 1.6.0.16 or whatever and click Finish. Right click on the top level of your project and click Properties. At the top of the popup window change the Java Platform to the one you just added and click ok. At that point, you should not experience your current problem when you compile.
JDK Download Link

You can set the Java version to be used in the project properties (right click on the project).
Edit: after seeing your specific error message: this seems to be a deeper problem. For some reason Netbeans is looking for a file sunrsasign.jar, which is not normally part of the JDK. Looking for the filename on Google indicates that it's part of a cryptography extension, but that seems to have been integrated into the JDK by now. So the JAR is not needed anymore.
I don't know whether it's Netbeans (are you using the most recent version?) or your application that is mistakenly looking for a JAR that has been integrated into the JDK library itselt.

Related

Error: "UnsatisfedLinkError: com.aparapi.internal.jni.OPENCLJNI.getPlatforms()" JNI configuration

I would try to execute an example script based on Aparapi, on MAC OS. I'm using the last version of Eclipse, but when I execute DeviceInfo example to get all the available devices:
public class DeviceInfo {
public static void main(String[] args) {
KernelPreferences preferences = KernelManager.instance().getDefaultPreferences();
System.out.println("-- Devices in preferred order --");
for (Device device : preferences.getPreferredDevices(null)) {
System.out.println(device);
}
}
}
it generates the
java.lang.UnsatisfiedLinkError: com.amd.aparapi.OpenCLJNI.getPlatforms()Ljava/util/List"
Is there someone who can help me?
build the native assembly for Mac (x86_64) and add it into jniLibs; here's the source code.
java.lang.UnsatisfiedLinkError generally means, that it cannot find the native assembly.
Despite macOS Mojave 10.14.4 don't support directly OpenCL, I've executed Aparapi Framework.
I founded that the problem is the Aparapi Library. In particular, to resolve generated error I followed these steps:
Download this repository https://github.com/aparapi/aparapi for AMD Graphic Cards
Open the directory "com.amd.aparapi" and from terminal execute
ant -f build.xml
This command generates .jar file of this library
Add the generate jar to the project's classpath in Eclipse
Add the specific Aparapi library for your OS in:
<your-workspace-path>/<your-project>/src/main/resources/osx/
Before to execute the code, add the VM argument in "Run Configuration"
-Djava.library.path=<your-workspace-path>/<your-project>/src/main/resources/osx/
Execute your script!

Project works in Eclipse but when imported into IntelliJ IDEA I get the JasperException re: CharSequence

I have been handed an application which is almost 10 years old, for maintenance. A customer (internal) has a requirement change. The app was built and maintained in Eclipse to this point. I need to import it into IntelliJ (the current company "standard") to implement the requirements change.
The app is running on a Websphere server in production, so the local debug environment is Jetty in the project which allows developers to open the app for debugging using localhost:(portNumber). The application will run and debug using Eclipse - I've taken the time to verify this. When I attempt to run or debug it (exact same code on the local harddrive) using IntelliJ, the application will start up, but as soon as I hit a certain JSP and it attempts to load an included JSP, I get the following error message (formatted for legibility):
org.apache.jasper.JasperException: Unable to compile class for JSP||
An error occurred at line: 6 in the jsp file:
/lookupFiles/myCodes.jsp|Generated servlet error:|
The type java.lang.CharSequence cannot be resolved.
It is indirectly referenced from required .class files||
I have done the code searches that I can think to do, and I don't have CharSequence anywhere in the application. I have been through the Google searches and numerous recommended solutions (most of which say to roll back from Java version 8 to 7). I am using JDK 1.8.0 build 102 with my environment set to source compatibility for Java 6 (what's on the server). So, I don't think the default methods are the issue.
Here is the code in the included file (line 6 is the opening JSP tag):
<jsp:useBean class="commands.CommandReciever" id="receiver"></jsp:useBean>
<%#page import="my.json.JSONObject,my.json.HTTP"%>
<%#page import="org.json.JSONArray" %>
<%#page import="commands.AjaxCommand" %>
<%
JSONObject obj = HTTP.toJSONObject(request);
obj.put("operation","select");
obj.put("index",3);
obj.put("tableNumber",100);
AjaxCommand command = new AjaxCommand("username", obj);
receiver.executeCommandSQL(command);
JSONArray jArray = command.getResults();
String keyCodes = "";
String keyValues = "";
if(jArray.length() > 0){
int ctr = 0;
out.println("<option value=\"\"> - </option>");
while(ctr < jArray.length()){
obj = (JSONObject)jArray.getJSONObject(ctr);
keyCodes = obj.optString("KEY_ID");
keyValues = obj.optString("LONG1_TX");
out.println("<option value=\"" + keyCodes.substring(1) + "\">" + keyCodes + " - " + keyValues + "</option>");
ctr++;
}
}
%>
I have checked the dependencies, the local classes which are imported don't implement any of the CharSequence implementation classes.
Finally, I know there are a lot of things which can be done to make this code "better" but I'm not needing that, I just need to figure out what is causing this JasperException and get past it so I can get the application to debug in IntelliJ.
I have moved past this problem and I want to post the solution that worked for me in CLEAR TERMS. It seems that the other solutions may have been correct, but not CLEAR. There is a bit of explanation, but the final fix is at the end.
I was developing on JDK1.8.0 bld 102 and setting the application configuration to fall back to build against Java 1.6 standards. I had installed JRE 1.6, JRE 1.7, and JRE 1.8 on my machine. I attempted to run my code against JRE 1.6, as the server is running Java 6, but this didn't help. IntelliJ IDEA was still BUILDING against and using the JVM from JDK1.8. I downloaded JDK1.7 and installed it alongside my JDK1.8 install and reconfigured IntelliJ to use the JDK1.7 for builds AND running the app locally. This fixed my issue.
So, the final fix was to set my Gradle JVM to use JDK1.7.0_80 rather than JDK1.8.0_102 - the IntelliJ IDEA Project SDK is still set to 1.8.

Cannot use installed java 3d

hi i'm trying to use java 3d in both command prompt and in netbeans. I have a win8 64 bit computor. I installed j3d-1_5_2-windows-amd64.exe. and it got installed inside java folder in a folder called Java3D. then I added an environmental variable as CLASSPATH and the values are C:\Program Files\Java\Java3D\1.5.2\lib\ext\j3dcore.jar;C:\Program Files\Java\Java3D\1.5.2\lib\ext\j3dutils.jar;C:\Program Files\Java\Java3D\1.5.2\lib\ext\vecmath.jar.
my file get compilled without errors when I try to runit from command prompt using the command java -cp . Hello3d it gives a calss not found error for javax/media/j3d/Node. and when i try to import 3d libraries from netbeans it gives an error on j3d after import com.sun. the following is the class I compiled from command prompt. please tell me what i'm doing wrong. thanx in advance
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;
public class Hello3d {
public Hello3d()
{
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
group.addChild(new ColorCube(0.3));
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main( String[] args ) {
new Hello3d();
}
} // end of class Hello3d
You use an obsolete version (1.5.2) of Java3D, this version is no longer maintained since a few years. Please uninstall it and install the latest version (1.6.0). Follow my instructions here.
Your code runs perfectly in my eclipse environment using java3d version 1.5.2.
It shows an ugly cube seen from one side only, red faced.
I guess you need to set the path to the native libraries that java3d needs.
Regrettably, I don't know how to do this on windows (R).
Regrettably I have not enough reputation to put this into a comment rather than an answer.
If anyone with enough reputation cares, please turn this answer into a comment.

SunTlsRsaPremasterSecret KeyGenerator not available

I encountered an error when my application tries to load a RSA Algorithm provider class from JAVA. The exception stack is as follow:
javax.jms.JMSException: RSA premaster secret error
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1255)
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1350)
at org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:388)
at com.trendmicro.tmsm.TMSMAgent.open(TMSMAgent.java:63)
Caused by: javax.net.ssl.SSLKeyException: RSA premaster secret error
at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(RSAClientKeyExchange.java:97)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:634)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:226)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at org.apache.activemq.transport.tcp.TcpBufferedOutputStream.flush(TcpBufferedOutputStream.java:115)
at java.io.DataOutputStream.flush(DataOutputStream.java:106)
at org.apache.activemq.transport.tcp.TcpTransport.oneway(TcpTransport.java:167)
at org.apache.activemq.transport.InactivityMonitor.oneway(InactivityMonitor.java:237)
at org.apache.activemq.transport.WireFormatNegotiator.sendWireFormat(WireFormatNegotiator.java:168)
at org.apache.activemq.transport.WireFormatNegotiator.sendWireFormat(WireFormatNegotiator.java:84)
at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:74)
at org.apache.activemq.transport.failover.FailoverTransport.doReconnect(FailoverTransport.java:715)
at org.apache.activemq.transport.failover.FailoverTransport$2.iterate(FailoverTransport.java:115)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.security.NoSuchAlgorithmException: SunTlsRsaPremasterSecret KeyGenerator not available
at javax.crypto.KeyGenerator.<init>(DashoA13*..)
at javax.crypto.KeyGenerator.getInstance(DashoA13*..)
at com.sun.net.ssl.internal.ssl.JsseJce.getKeyGenerator(JsseJce.java:223)
at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(RSAClientKeyExchange.java:89)
... 22 more
I've googled the error message and most of posts says it's because JVM cannot find sunjce_provider.jar. However, I can find the file in /Library/Java/Home/lib/ext folder.
The platform is Mac OS X 10.6 and Java version is 1.6.0_17.
My questions are:
Why JVM does not search /Library/Java/Home/lib/ext for jar files?
Can we change CLASSPATH or java.ext.dirs property by modify any config file?
Any suggestion to solve this problem?
Thanks in advance.
I've had the same problem after upgrading to new Java version on Mac.
My (maven) project ran OK from command line but got the "SunTlsRsaPremasterSecret" error in Eclipse.
The solution was to remove Installed JREs in Eclipse configuration and add them again (using the "Search..." button).
had a similar issue. Adding the classpath to the ext directory fixed it for me. This fix worked for me on windows 7 with java 1.6
java -Djava.ext.dirs=lib -classpath "%java_home%\lib\ext\*" myapp.jar
I think we find the root cause so here is an answer of my own question.
the Java system property "java.ext.dirs" in Mac OS X 10.5 is:
/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext. The sunjce_provider.jar should be in /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext but also be found in /Library/Java/Extensions/ in the problem mac.
the sunjce_provider.jar in /Library/Java/Extensions/ belongs to Java Cryptography Extension(JCE) 1.2.2, which has been installed in the mac. JCE 1.2.2 is an optional package of J2SE 1.3.1 and may not includes enough libraries for J2SE 1.4 and later.
the Java applcation works normally after all JCE 1.2.2 related jar files have been removed from /Library/Java/Extensions/.
It happened to me while launching the tomcat server from eclipse. I solved it by changing the configuration in Windows -> Preferences -> Java -> Installed JREs -> Edit. I had to update all the JRE system libraries with the corresponding jars from the folders in:
%JAVA_HOME%/jre/lib/ext
%JAVA_HOME%/jre/lib/
It seems that after the last update I have changed the JRE_Home but forgot those libraries.
I also had this issue, noticed that the problem was in my Eclipse configuration.
Window > Preferences > Java > Installed JREs > jdk8_64bit > Edit...
The path of my sunjce_provider.jar was pointing to jdk8_64bit\lib\ext\sunjce.provider.jar. It should point to the JRE's equivalent in jdk8_64bit\jre\lib\ext\sunjce.provider.jar.
Had to spend almost a day on this while trying to use JavaMail in Eclipse Luna.
Tried all approaches suggested in various forums, but no luck.
Digged into the complete flow and found the exception arising due to Class is on BootClassPath
from KeyAgreement.getInstance()->JceSecurity.canUseProvider()->JceSecurity.getVerificationResult()->JarVerifier.verify()
void verify()
throws JarException, IOException
{
if (jarURL == null) {
throw new JarException("Class is on the bootclasspath");
}.......
I removed sunjce_provider jar from \ext\ folder and can send mail now.
This might not be right but atleast a quick workaround.
Refer Eclipse bug.
I know, I am joining late here. But for me, this error came suddenly as soon as I changed the Preference -> Java -> Installed JREs -> Execution Environments as JavaSE-1.8 to jdk1.8 path. But it should be jre1.8 path.
I don't know why is it happening now. But It sorted the problem.
Probable solution: Check if jdk path is set till C:\Program Files\Java\jdk1.8.0_171 but not including bin
In my case, I got above same issue, after reading above solutions, I changed JRE Definition and Restore Default. It is working fine now.

NoSuchPortException using RXTX Java library on Windows?

I have followed the instructions to setup rxtx on windows from http://www.jcontrol.org/download/readme_rxtx_en.html.
What I did exactly was copy rxtxSerial.dll to "C:\Program Files\Java\jdk1.6.0_07\jre\bin"
and copied RXTXcomm.jar to "C:\Program Files\Java\jdk1.6.0_07\jre\lib\ext"
(my JAVA_HOME variable is set to C:\Program Files\Java\jdk1.6.0_07\jre)
I also added RXTXcomm.jar to my eclipse project.
But when I run it, it still says "NoSuchPortException"
Devel Library
=========================================
Native lib Version = RXTX-2.0-7pre1
Java lib Version = RXTX-2.0-7pre1
java.lang.ClassCastException: gnu.io.RXTXCommDriver cannot be cast to gnu.io.CommDriver thrown while loading gnu.io.RXTXCommDriver
gnu.io.NoSuchPortException
at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:218)
at TwoWaySerialComm.connect(TwoWaySerialComm.java:20)
at TwoWaySerialComm.main(TwoWaySerialComm.java:107)
In my java file, I tell it:
try
{
(new TwoWaySerialComm()).connect("COM4");
}
and I've also tried the Java Comm API. Both cannot recognize my serial port but I am sure I followed the instruction correctly. There files are there.
Does anybody have any idea what it could be?
Try putting rxtxSerial.dll in
C:\Program Files\Java\jdk1.6.0_07\jre\lib\bin
^^^
you can use
CommPortIdentifier.getPortIdentifiers()
to identify all possible ports your system finds.
I am not too familiar with RXTX, but is this normal?
java.lang.ClassCastException: gnu.io.RXTXCommDriver cannot be cast to gnu.io.CommDriver thrown while loading gnu.io.RXTXCommDriver
Otherwise maybe the problem is not with the port itself after all, but something with the classes themselves?
Just a guess.
You can also try an alternative solution that was specifically implemented for Windows. There should be plenty available, one of them you can get from http://www.caerustech.com/JCommWin32.php
Shultz
It may be that your system does not have a COM4 defined or it's not accessible. It's hard to guess what may be wrong, because you haven't posted you port init code - what you posted looks like wrapper code.
Here is my working init code using the javax.comm API (but using SerialPort from serialio.com):
// name comes from config and is "COM1", "COM2", ...
SerialPort port=(SerialPort)CommPortIdentifier.getPortIdentifier(name).open("YourPortOwnerIdHere",5000); // owner and ms timeout
port.setSerialPortParams(bau,dtb,stb,par);
port.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN|SerialPort.FLOWCONTROL_RTSCTS_OUT);
port.enableReceiveTimeout(1000);
Hopefully this points you in the right direction.
I agree that you're problem looks like a ClassCastException and not the other.
For windows, I'm using "Windows Java Serial Com Port Driver" at http://www.engidea.com/blog/informatica/winjcom/winjcom.html and it is much easier for me to set up.
In either case, you want the DLL in the BIN directory, not LIB\BIN as was suggested. At least that's what's working for me. I'm using NetBeans and I've also found it helpful to put the jar and dll into various bin and lib\ext folders in the JDK.
Note that if you have multiple versions of the JRE on your machine, you might not be using the one that you think you are using. Also, as a practical matter I've found it more helpful to just copy both the jar and dll into the various bin and lib\ext folders. Makes it just a paste, paste, paste operation.
For windows, I recommend "Windows Java Serial Com Port Driver" because it solved my problems with USB serial ports. I had fits with RXTX because it would crash when the USB was unplugged. winjcom solved that problem and others as well. It has very helpful error exceptions.
Also, make sure your serial drivers are up-to-date. Downloading an update fixed my other bug.
-Stosh
I also had a problem when closing the serialPort within the serialEvent function.
Maybe it's a deadlock problem, where the close method waits forever for serialEvent's lock to be released.
Starting a new thread to close the port worked for me.
For your question, my code is the following:
if (idPuerto == null)
{
formulario = form;
boolean encontrado = false;
listaPuertos = CommPortIdentifier.getPortIdentifiers();
while( listaPuertos.hasMoreElements() && encontrado == false )
{
idPuerto = (CommPortIdentifier)listaPuertos.nextElement();
//System.out.println(idPuerto.getName());
if( idPuerto.getPortType() == CommPortIdentifier.PORT_SERIAL )
{
if( idPuerto.getName().equals(RFIDBascApp.ComBasc) )
{
encontrado = true;
logger.AddInfoUser("Puerto serie encontrado");
}
}
}
You had NoSuchPortException, so first of all iterate on all available ports!
import gnu.io.CommPortIdentifier;
import java.util.Enumeration;
public class ListAvailablePorts {
public void list() {
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
while(ports.hasMoreElements()){
CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
System.out.println(port.getName());
}
}
public static void main(String[] args) {
new ListAvailablePorts().list();
}
}
#Pinheiro you might want to take a look at this

Categories

Resources