I am trying to use GLPK for my java project. I followed the link here https://wiki.nps.edu/pages/viewpage.action?pageId=113606659 to install and config the GLPK for java. And in the java project, I used
compile 'org.gnu.glpk:glpk-java:1.12.0'
to include the glpk java project. However, when I try to create the test class in my project , then it gives the following error.
public class ILPTest {
#SuppressWarnings({ "rawtypes", "unchecked"})
public static void main(String[] args) {
testGLPK();
}
private static void testGLPK() {
System.out.println(GLPK.glp_version());
}
}
The GLPK in the statement GLPK.glp_version() can not be resolved.
UPDATE: One thing I noticed is in the link I posted above, I have an error when I try the step 11 sudo make install as below
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
So when I try to run sudo ldconfig (from another url http://glpk-java.sourceforge.net/gettingStarted.html), I got a command not found error. Can anyone help here? Thanks in advance.
It turns out that I need to manually add the lib glpk-java-1.12.0.jar into the project.
Related
I'm trying to deploy a program that I created but I'm having an error after the installation.
I used Native Packaging to package it as an EXE installer and when I click said installer, it says the main class cannot be found. Here are some screenshots of the error:
Why is it not finding the class?
This is not always the best method.
However, I had the same problem but it was solved.
First, if you are using kotlin,
Create a main class that will be the new entry point as a Java file.
The generated Java file should be as follows:
package {your_package};
import javafx.application.Application;
public class EP extends Main {
public static void main(String... args) {
Application.launch(args);
}
}
The Main should be the class that seems to be the current entry point.
Perhaps the Main is defined as open class Main: Application () {.
Set the EP class generated this time as the entry point (main class).
If exe is generated as -native image,
Please try to execute the generated exe, paying attention to the following points.
○ Make sure the generated directory does not contain spaces or multibytes.
○ Do not execute directly from USB etc. (Copy to PC and execute)
I ran into the exact same issue. I used maven and spring boot for the project. So after using maven to build the jar first then used org.springframework.boot.loader.JarLauncher for the -appclass option. Problem solved.
So I am very new to using Github with Eclipse. When I import a project into eclipse by using the HTTPS clone URL and try to run it, it gives me the error:
Error: Could not find or load main class UserEnviorment.Main
The project is stored in:
Macintosh HD > Users > Kyle > git
but the Eclipse workspace is somewhere else. Would this cause problems?
Here is the class I am trying to run if that helps any
package UserEnviorment;
import java.util.*;
public class Main
{
public static void main(String[] args) throws Exception
{
// Does stuff until user exits program.
}
}
I apologize if this is a stupid question, but any help is much appreciated!
Nevermind, I seem to have found a solution. If I delete the project in Eclipse but don't remove the files from my hard drive, I can then create a new Java project in Eclipse and uncheck the box "use default location" and navigate to where the Github project is stored.
I'm trying to compile and run the tooltip code from this tutorial. I obtained QtJambi from my package manager (the package is qtjambi-beta from AUR), which installed it into the directory /opt/qtjambi-beta/. In particular, the qtjambi-4.7.0.jar file is located at /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar.
Now, I made a folder called qtpractice and put the example in there under the name JambiApp.java. The code I put into it was exactly as follows (following the example I linked):
package qtpractice;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QWidget;
public class JambiApp extends QWidget {
public JambiApp() {
setWindowTitle("Tooltip");
setToolTip("This is QWidget");
resize(250, 150);
move(300, 300);
show();
}
public static void main(String args[]){
QApplication.initialize(args);
new JambiApp();
QApplication.exec();
}
}
I compiled it with javac qtpractice/*.java -cp /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar, which worked fine. I then tried to execute it with java qtpractice.JambiApp, and I got the following error:
Error: Could not find or load main class qtpractice.JambiApp
EDIT: Based on some advice from the comments, I tried this command instead: java -cp /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar qtpractice.JambiApp
. When I did this, I got the following error again:
Error: Could not find or load main class qtpractice.JambiApp
What did I miss? From what I can tell, I did everything necessary to make it execute.
You need to include all jars Qt Jambi needs in classpath.
This can be done on CLI with command similar to
java -cp /opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-4.7.0.jar:/opt/qtjambi-beta/qtjambi-linux64-community-4.7.0/qtjambi-linux64-gcc-4.7.0.jar:. qtpractice.JambiApp
When compiling, native jar does not need to be present, as the native libraries are just for Jambi classes to be able to use Qt.
Here's my code which sets up the server using Jersey+ Grizzly combination from here. I haven't modified anything. also, all my files in the package com.example.
package com.example;
A rough skeleton of the Main.java which has the main(String[] args) is:
public class Main {
public static void main(String[] args) throws IOException {
code;
}
}
Also, there are other .java classes which don;t have main method. The project is being built by Maven and I use IntelliJ. The two execution profiles I have are:
Working directory : Z:/IdeaProjects/com.example with command line arguements:
clean test and exec:java
I understand that i need to run my Main but I don't know how to do it via Maven+IntelliJ. Can someone please help me?
I'm not sure exactly what you are trying to do, but I usually just right click on the main method and then click on the Run option. If you haven't downloaded all your dependencies, then go ahead and click on the Maven Projects tab, on the right side of the screen and run the compile stage to download all of your dependencies.
If you attached the error message you are getting that might help us narrow down the issue you are having.
You need a directory per package component. The path should be com/example/Main, not com.example/Main.
I'm experimenting with Aspect-Oriented Programming. I've installed the AspectJ-Plugin in Eclipse and followed all the steps mentioned in this tutorial.
All connections between the created aspects work, but when I try to run the project, I receive the following exception:
HelloException in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 6 in method helloworld.World.<clinit>()V at offset 0
at helloworld.Hello.sayHello(Hello.java:11)
at helloworld.Hello.main(Hello.java:6)
When I empty the class World.aj and run the project, everything works and I receive the expected "Hello" in the console.
Here are the classes I created during the tutorial:
Hello.java
package helloworld;
public class Hello {
public static void main(String[] args) {
sayHello();
}
public static void sayHello() {
System.out.print("Hello");
}
}
World.aj
package helloworld;
public aspect World {
pointcut greeting() : execution(* Hello.sayHello(..));
after() returning() : greeting() {
System.out.println(" World!");
}
}
the problem doesn't seem related to AOP.
I think this is the same eclipse bug described here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362591
Ayushman Jain 2011-11-02 02:47:32 said:
If you're stuck, please use the VM argument -XX:-UseSplitVerifier to run the
program. I confirm that there is no verify error with this option.
May you can also try to download the latest version of eclipse.
I don't have the points to comment on #KC answer, which worked for me,
so leaving this as an additional answer
-XX:-UseSplitVerifier
did work for me
I have an AspectJ project that was running fine in eclipse 3.7
then all of a sudden started getting that error
adding the -XX:-UseSplitVerifier to the launcher configuration solved it.
I also followed the tutorial, and encountered the same error. And here is how I solved it.
I found out that that the execution environment JRE selected by default with my eclipse, JavaSE-1.7, had an issue with AspectJ. So what you have to do, is change the execution environment JRE, choose for example JavaSE-1.6.
After, you can follow the tutorial, and obtain the desired output! :)
Hope this helps!