VLJC imports not being recognized - java

I'm trying to use VLCJ for the first time and I downloaded the dist they have at their site's tutorial.
I unzipped the dist inside of my project's source folder, then went to my IDE (Netbeans) and went into Libraries and added all of the .jar files that were now laying in the src folder.
However, I still get the error about the IDE not recognizing these libraries.
package uk.co.caprica.vlcj.factory does not exist
Furthermore, I'd like to know. If I share this code with someone who has never touched neither VLC nor VLCJ, will they be able to run the program with their IDE and see the video that its supposed to play? One of my concern's is that apparently the user needs to have VLC installed.
import java.awt.event.*;
import javax.swing.*;
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
public class Tower {
public static void main(String[] args) {
MediaPlayerFactory factory = new MediaPlayerFactory();
}

Related

decompiling .jar file using jd-cmd API

So I was searching for a command line tool to de-compile .jar files, I found this "jd-cmd" at https://github.com/kwart/jd-cmd and it worked fine, but now I saw it has an api that I can use, I can't seem to do it the wright way. I am working on intellij IDE, added the external jars to my project, all I want is that the output will be at a folder of my choice in the filesystem just like it works at the command line with no problems.
here's an example code I tried from the idea that didn't do the job:
import java.io.File;
import jd.core.input.JDInput;
import jd.core.input.ZipFileInput;
import jd.core.output.DirOutput;
import jd.core.output.JDOutput;
import jd.ide.intellij.JavaDecompiler;
public class App {
public static void main(String[] args) {
JavaDecompiler javaDecompiler = new JavaDecompiler();
//choose input plugin for your decompiled file (class, zip, directory)
JDInput jdIn = new ZipFileInput("path/to/myFavorityLib.jar");
//choose output plugin (zip, directory, console)
JDOutput jdOut = new DirOutput(new File("/tmp/decompiled"));
//decompile
jdIn.decompile(javaDecompiler, jdOut);
}
}
This code didnt generate decompiled files at "/tmp/decompiled"
ok, so i have managed to do it .
it was a dependency problem , the github developer mentioned that jd-lib folder should be added as a dependency library , but actually it dosent matter that much ,you need to add a jar file :after doing all the instructions and downloding what ever maven will give you, at the folder jd-cli there a downloaded jar "jd-cli.jar" , use this as a dependency for your project and it work just fine!

Why "GLProfile.GetDefault()" works while running in NetBeans but not when running Jar

I'm making a simple window that renders a moving triangle using the Java OpenGL libraries (jogamp) latest stable build 2.2.4, I've got everything set up like the tutorials I found on the JOGL website, the thing is while running this code on Netbeans it works fine, the method GetDefault() gets my systems OpenGL version, the window renders and also the animation. The problem is when I build the project, I make sure all the jars and .dll files are in the /dist folder and execute the Jar with "java -jar name.jar" I get the following error message:
Exception in thread "main" javax.media.opengl.GLException: Profile GL_DEFAULT is not
available on null, but: []
at javax.media.opengl.GLProfile.get(GLProfile.java:962)
at javax.media.opengl.GLProfile.getDefault(GLProfile.java:693)
at javax.media.opengl.GLProfile.getDefault(GLProfile.java:704)
at cl.lucas.clases.Main.main(Main.java:14)
This is my Main class code:
import com.jogamp.opengl.util.FPSAnimator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
public class Main {
public static void main(String[] args) {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
Frame frame = new Frame("AWT Window Test");
frame.setSize(300, 300);
frame.add(canvas);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
canvas.addGLEventListener(new EscenaSimple());
FPSAnimator animator = new FPSAnimator(canvas, 60);
animator.start();
}
}
Any ideas why it would work only on the IDE but not outside, also I'm running Windows 7, I also tried running the program on Eclipse and no problem there, the thing is the jar executable, maybe I'm missing something.
Your fat JAR is probably incomplete, mine works flawlessly under GNU Linux, OS X and Windows. You must follow this layout, you can use this Ant script within Eclipse to make it work. My detailed instructions are here and they work even though you use only JogAmp without the engine mentioned in my tutorial.
Numerous developers already asked us lots of questions about fat JARs, rather contact us on our official forum. You don't need to put the native libraries (DLLs under Windows) into a particular directory, setting the Java library path is necessary only if you don't use the JARs containing the native libraries, just keep the automated native library loading enabled (it's on by default) and GlueGen will detect your architecture, extract the proper native libraries (for JOGL, JOAL and JOCL) and load them.
If you really want to use the "-jar" option, your JAR must contain absolutely everything needed for your application to run and in the expected location. Read carefully the paragraph of my tutorial, you have to set at least the manifest attribute "Main-Class" to make it work properly, so that Java can find the main entry point of your application.

Importing voce.jar into a java file properly

I have downloaded a voice/text API for java from
http://voce.sourceforge.net/
However being semi new to java I am unsure how to use all these jar files in my code, have tried several things like import voce, import java.voce, package (my folder name with the voce jar inside).
However I am getting no luck.
Code I am trying is
import java.voce;
public class SpeechInterface
{
public static void main(String[] args){
voce.SpeechInterface.synthesize("hello world");
}
}
Error I get is that it cant find voce(since I am obviously doing this wrong). Have looked through stackoverflow but was unable to find a question that answers this. I imagine there is one like this already but I can not find it. Closest I could find was the importing voce to C, but that wasn't to helpful.
The jar file is in same directory as the java file.
try using
import voce.*
If you look at http://voce.sourceforge.net/api/java/_speech_interface_8java-source.html
It mentions the package as (package voce).
Here under the Tab no 10. You can find how to add a Jar file to Dr.Java IDE,
Then as Kakarot Mention , you should to write
import.voce.*;
if you need all the classes of package voce,
or write
import.voce.classname
to import a specific class.

package javafx.media does not exist

I'm new to programming and don't know what to do... jGRASP gives this error (the title) when i try to run an mp3 file using java via this code :
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.Media;
public class hehe{
public static void main(String[]args){
String krow="hoho.mp3";
Media trial = new Media(krow);
MediaPlayer Ply = new MediaPlayer(trial);
Ply.play();
}
}
I searched for a solution but couldn't find one.
You need to download e(fx)clipse plugin or use NetBeans or IntelliJ. If you are using 'regular' Eclipse, you need to add jfxrt.jar to your classpath.
What you are using is JavaFX. It comes along with your JDK. However, jfxrt.jar is not on standard classpath.
In spite of resolving that, your program won't run because running JavaFX program is different from running 'usual' Java programs. You need to extend the Application class and create a scene graph.
Have a look here on how to get started.

Where to get com.sun.j3d classes

I have found some code snippet in the internet. But it is missing some classes. Where can I get the missing classes?
These are the errors I get:
package com.sun.j3d.utils.universe.SimpleUniverse doesn't exist
package com.sun.j3d.utils.geometry.ColorCube doesn't exist
package javax.media.j3d.BranchGroup doesn't exist.
Here is the code :
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();
}
}
You'll need to include the Java3D libraries in your class path.
You can get them from java3d.java.net. There's a couple of options, but you could download the build zip for your architecture, unzip it, unzip the j3d-j3d.zip, navigate to lib/ext and copy the jars you find into your classpath (-classpath path\to\j3dutils.jar for example)
We'll need more info about your environment (Are you using an IDE? Which one? Using javac from the command line? What command are you using?) if you need more help.
Looks like maybe you don't have the java3d library installed? If you go to sun and look for java3d, they have a decent installer. If you're starting with a jdk from the sun site, the installer seems to find the right place for the java3d classes within the existing jdk/jre directory.

Categories