I have the last Ubuntu version on my computer and i tried many times to install the library Libsvm,following the instructions at this link: https://www.php.net/manual/en/svm.requirements.php.
The link is for installing the library in php,but to add the php extensions,the library need first to be installed in java.
I hadn't any problems with this commands,(obviously,i typed all the commands for the latest version of the library,3.24)but when comes the moment to compile the test file.java with the javac command,the compiler doesn't recognise my SVM class...
Here I paste the code in the java file.
svm_predict svm = new svm_predict();
And I also tried this :
LibSVM svm = new LibSVM();
I'm really desperate,please give me a hint!
In order to use libsvm within your Java project, you need to add the corresponding JAR file (libsvm.jar) to your classpath.
I suggest to use an IDE (such as Eclipse or IntelliJ) for Java programming in order to manage the libraries in your classpath.
If you prefer to stay with command-line compiling via javac, you can use the parameter -cp to add libraries to your classpath. You can find details for it in this post on Stackoverflow.
Related
I've been trying to set up on JavaFX in VSCode. I added the JavaFX jar files to the referenced libraries and added the following statement to launch.json (obviously with my path to the lib folder):
"vmArgs": "--module-path \"C:/path/to/javafx-sdk-19/lib\" --add-modules javafx.controls,javafx.fxml"
This is exactly what multiple youtube videos and other StackOverflow posts have said to do, but I still keep getting this error.
(I know that I can use Maven or Gradle in VScode but am completely unfamiliar with both and still want to try to make this work.)
Hopefully I didn't miss anything painfully obvious but thank you for any help.
You should download JavaFX for your JDK version.
Uncompress JavaFX.zip and move bin folder to your project.
You should create two classes, one for writing the JavaFX window code and one for running it.
The error can be fixed.
I suggest you learn how to use Maven or Gradle in vscode. It is very important.
At runtime, your app needs access to the JavaFX (OpenJFX) libraries.
Either:
Install a copy of the OpenJFX libraries with your app, as directed in the Answer by RedSnack-BCS.
Replace your Java implementation with one that includes the OpenJFX libraries.
I know of two such implementations of Java (JDKs) that include necessary libraries:
ZuluFX, a special edition of their Zulu product, by Azul Systems.
LibericaFX, a special edition of their Liberica product, by BellSoft.
You may have identified a third approach with the use of passing arguments to the JVM. But I am not familiar with that solution.
I am trying to use WFDB toolbox for Matlab from Physionet in GNU Octave. One prerequisite is having GNU Octave 3.8.1 or later with the Java package, so I have compiled it for my Debian 7.8 and then installed Java package from within Octave. I am not sure to have correctly proceeded with compilation, I had some issues with Java interface during the configuration.
The problem is that when calling a Java method from Octave, I get this error:
error: javaMethod:
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/client/libjvm.so:
failed to load:
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/client/libjvm.so:
cannot open shared object file: No such file or directory
I have checked if the file exist or not, and I found out that the "client" folder does not exist. On the other hand, the "server" folder is present and I have also found
/usr/lib/jvm/java-1.5.0-gcj-4.7/jre/lib/amd64/client
I cannot figure out why these files are missing, I am not a Java programmer nor GNU/Linux specialist.
Thank you very much for your help.
You don't need to install the java package. The functions in the java package have been merged into the Octave core language for the 3.8 release. You don't need to do anything, java should work out of the box for you (provided you didn't mess up while building it). If you installed the java package on your Octave 3.8 install, you are probably shadowing its own functions.
I'd recommend that you use the Octave version on the Debian repositories. You are using Debian 7 (wheezy), so you can use wheezy-backports which already have Octave 3.8.2. No need to faff around with building from source if you are not familiar with it and Debian already provides one for you.
Can I execute Eclipse Java development tools as a standalone process? I need to get Java program's AST structure using Eclipse JDT from another program, and to do that, I need to execute eclipse plugin as a stand-alone process behind the scene.
Is that possible? If so, how one can do that?
Eclipse/jdt and eclipse/ast is nothing more than a jar file, so one can use them to build standalone java application.
Example
I googled to find ASTExplorer as an example to make eclipse/ast plugin as a standalone java project.
The program was targeted for pretty old eclipse (3.0.2), I downloaded the 3.0.2 for Mac OS X this site - http://archive.eclipse.org/eclipse/downloads/drops/R-3.0.2-200503110845/
You need to setup ECLIPSE_HOME classpath variables in Preference -> Java -> Classpath variables
The .classpath has those classpath variables already, you can refer to this post - .classpath contents update in eclipse. As you can see it refers eclipse/jdt(art) jar files. I'm pretty sure one can change the reference to the newest version of jdt/ast without downloading the 3.0.2 version.
As I use Mac, I need to replace the swt for PC with swt for Mac. I could do that in BuildPath/Configure Build path
First remove the PC swt reference.
Then add the correct Mac swt reference.
Compile the example with the eclipse indigo/on mac
When the setup is correct, eclipse starts building the project. You can use Project -> Build Project menu. Then, you can check the application works fine in eclipse.
Generate the executable jar
Export to executable jar file.
You'll get some warnings, but you'll have a jar file.
Execute the generated jar
Just executing java -jar ast.jar doesn't work on Mac, I got a hint from this post.
Running SWT based, cross-platform jar properly on a Mac
In short, you need to run java -XstartOnFirstThread -jar ast.jar
Does it have to be Eclipses's AST? Or is any AST generation o.k.? If it doesn't have to be eclipse, I'd suggest Habelitz open source Java AST Compiler. http://www.habelitz.com/ I'm using it myself for some projects....
Well, of course you can launch eclipse just like any other process : How to create a process in Java
And then the problem becomes relaying the information back to the original process, which gets kind of messy. My suggested approach in this case would probably be to create a plugin in eclipse and have that plugin do whatever it is you think you need the AST for. You can work out messages with command line options to eclipse, or a shared file or something.
Let me start by saying I've recently inherited a Java application written using Eclipse. I'm new to this language/IDE, but I have a lot of experience with C# and Visual Studio. So, my problem may be something very silly, but I have a foundation so I'm not a total programming newb.
I'm exporting this project as a runnable JAR, using a launch configuration provided by the original developer. I have tried this with both "Extract required libraries into generated JAR" and "Package required libraries into generated JAR". Either way, I get the following error when I launch the application:
java.lang.NoClassDefFoundError: javax/media/jai/PlanarImage
I launch the application using this command, where appName.properties is a properties file that's required for running the app:
java -jar appName.jar appName.properties
This occurs multiple times from separate stack traces. I'm not seeing any other runtime errors or compile errors. My JRE system library is jre1.5.0_05. I installed JAI by downloading jai-1_1_3-lib-windows-i586-jre.exe from http://download.java.net/media/jai/builds/release/1_1_3/ and installing it into the jre5 directory. My project did not compile until I got this specific version of java, and installed the JAI jre into that version's folder, so I am fairly certain I have that part together correctly.
Finally, here is my classpath:
C:\Program Files (x86)\Java\jre1.5.0_05\lib\ext\jai_codec.jar;C:\Program Files (x86)\Java\jre1.5.0_05\lib\ext\jai_core.jar;C:\Program Files (x86)\junit4.10\junit-4.10.jar;.
Is there anything obvious I'm doing wrong here? Is there any other information that would be helpful in figuring out why I'm getting this error?
Make sure the jar is in your classpath. Are you running from an IDE or from command line?
There is Java tool (it is called Mallet)
http://mallet.cs.umass.edu/download.php
which I want to use in my .NET project.
To convert this tool to .NET library at first I've tried to build it in single .jar file using Apache Ant. I've done everything corresponding to instructions at link above.
Download Developer Release from Mercurial repository.
Download Apache Ant, install JDK, set JAVA_HOME var to use Apache Ant.
Using Ant I've built single mallet.jar file.
And then I would to convert mallet.jar to .NET library using IKVMC.
When converting, I've got a lot of warnings such as:
Warning IKVMC0108: not a class file "cc/mallet/util/tests/TestPriorityQueue$1.cl
ass", including it as resource
(class format error "51.0")
Despite of these warnings, mallet.dll was created. But when I try to reference to it from my .NET project, it looks "empty". It has not any classes or namespaces. I don't forget to reference to IKVM.OpenJDL.Core.
And this is unusual that I can't find any same problems in Google.
I think that problem is in warnings. And I have never worked with Ant and I don't understand all process exactly.
The class format version 51 was introduced with Java 7.
IKVM most likely doesn't support that version yet and the file name you quote (cc/mallet/util/tests/TestPriorityQueue$1.class) points at an anonymous inner class of TestPriorityQueue that certainly is needed for the library to work correctly.
My suggestion: compile Mallet using an older JDK or at least using the -source and -target switches set to 6 (to ensure that it's compile for Java 6).
FYI v8.1 (currently in RC) of IKVM supports Java 8:
http://weblog.ikvm.net/2015/08/26/IKVMNET81ReleaseCandidate0.aspx
http://sourceforge.net/p/ikvm/mailman/message/34502991/