MP3agic: https://github.com/mpatric/mp3agic
Example.java: https://github.com/mpatric/mp3agic-examples/blob/master/src/main/java/com/mpatric/mp3agic/example/Example.java
I have been programming in java for a few years but have never installed anything extra relating to java (like MP3agic) before, and I have absolutely no idea how to do it. Reading up on websites it seems like it should be as easy as double-clicking on the .jar file, but when I do that with MP3agic I still don't have any luck.
Listed on the link above are brief instructions on how to install it: download and install maven (which I've done correctly), run "mvn lean package" in CMD, then in the newly created 'target' folder there are three jars: mp3agic-0.8.5-SNAPSHOT/SNAPSHOT-javadoc/SNAPSHOT-sources.jar.
At this point I double clicked on them all and assumed it was installed, but when I tried to run an Example.java file made for MP3agic (link at top), Java couldn't compile it.
I have tried added the path of my 'target' folder in the Path Environment Variable, but that hasn't worked. I also don't use something like Eclipse for programming (just Notepad++ and CMD, although that's likely to change)
You have to specify the class path during compilation. (I donot use IDE , I use plain CMD + Notepad++)
write something like this :
javac -cp mp3agic-0.9.1-SNAPSHOT.jar; Example.java
provided both of them are in the same dir.
Worked for me
For people like me:
Maven Installation:
Download Maven (Zip File)
Unzip Maven (anywhere)
Add Maven to system eviorment variables (help)
Get MP3agic.jar
Download Zip
Unzip MP3agic (anywhere)
Open cmd in MP3agic path
run "mvn clean install"
Include MP3agic.jar (IntelliJ)
Open project structor
Add Library -> Choose MP3agic.jar
Related
///WARNING- I DO NOT KNOW ANY LANGUAGES/HAVE NO USED ECLIPSE BEFORE\\
I'm currently trying to get a .jar file compiled in Java8 to compile in Java7, but seem to be having trouble, I have the source code intact so that is not the problem. It compiles fine, but the finished .jar is smaller than the original by a large margin. I believe the problem lies in my inexperience with Eclipse meaning I problably did something wrong.
Source Folder Structure
src\com\darkblade12\enchantplus...java files
Contents Of Each Folder
If you have some doubts about eclipse being behind the problem, try to compile it directly using the Command line Interface with the target version version of java by using javac.
Example for Windows:
set JAVA_HOME=C:\Program Files (x86)\Java\jre1.7.0_21
javac com/darkblade12/enchantplus/*.java
jar cvf program.jar -C com/darkblade12/enchantplus
Then compare your jar generated by eclipse and this generated directly from the command line.
Another way to verify is to open the jar file with and archive manager like 7-zip and verify its content.
So, I have exported my project in both Netbeans and Eclipse and when I try to
java -jar myproject.jar
I get this prompt
In my project I have some libraries which are located inside of src in Netbeans and out of src in Eclipse as it should (please correct me if I'm wrong) The libraries are included via:
Java Build Path > Add JARs...
I've done some research and it seems that I have to change my JAVA CLASSPATH or somethng like that but I don't know exactly how to do it.
The project works perfectly when I compile it and run it, but it crashes after I build it into a Jar file.
By the way, if it isn't clear enough I'm on Ubuntu 14.04
You need to create the path for the jar files and pass it on the command line.
Something like this:
ftp_jar=${Utils_home}/bin/ftpClientUtil.jar
net_jar=${Utils_home}/bin/commons-net-3.3.jar
jsch_jar=${Utils_home}/bin/jsch-0.1.51.jar
java -cp .:$jsch_jar:$net_jar:$ftp_jar com.myplace.ftputils.SFTPClientUtil $*
Run your program as:
java -cp .:[path-of-lib1.jar]:[path-of-lib2.jar] -jar myproject.jar
replace [path-of-libX.jar] with actual path of your libraries.
Hi I wrote wordquiz program on Java. Using Eclipse in Unix.
In my linux machine it works fine.
Here is a source code https://github.com/HighlanderGe/Words
So, only basic package is used.
In windows compilation of such code as jar doesn't run. Neither in Mac.
As I guess problem is that in linux it is made to run from console, and console is comething very native for linux, but in Windows and I think in Mac too, cmd should be called, and from there it somehow to run.. but I bet cmd has no idea what is java. So some java console is needed for it?
The problem is not with the Mac or Windows, the problem is that you did not setup your workspace in Eclipse the same way on your different computers.
You can build your program on the command line in all environments in the same way. You just have to know the right steps.
First of all, there's an error in your code on line 25 in WordDatabase. Instead of:
dictionary = new ArrayList<>();
it should be:
dictionary = new ArrayList<String>();
After that, you can build your code like this:
javac -d . *.java
And run it like this:
java wordquizz/Wordquizz
This should work in any system that has Java, you just need to figure out how to setup your workspace in Eclipse the same way on your different computers.
UPDATE
I forked and converted your project to a Maven project:
https://github.com/janosgyerik/StackOverflow-Words
After you clone this to your PC, you can import into Eclipse using the File | Import... menu, and then Existing Maven projects option. It should work on all operating systems.
Maven is a recommended tool for building Java projects and it's a good thing to learn. After you install maven, you can build the project with:
mvn compile
You can package the project into a jar file with:
mvn package
You can run your code with either of these commands:
# needs 'mvn compile' first to generate classes
java -cp target/classes/ wordquizz.Wordquizz
# needs 'mvn package' first to generate the jar
java -cp target/wordquizz-1.0-SNAPSHOT.jar wordquizz.Wordquizz
If you like these improvements, merge from my repo soon. I won't keep it forever, I will delete it at some point.
UPDATE 2
To make a jar executable, you need to add inside a manifest file like this:
Main-Class: wordquizz.Wordquizz
You create the jar file with a command like this:
jar cvfm package.jar manifest.txt wordquizz/*.class
I updated my GitHub repository, so that now if you run mvn package, it will automatically add the right manifest, and the generated jar file will be executable.
If you installed java under windows you have to adjust the Path-variable, so the cmd knows where the java executable is. A good tutorial on how to set this up you can find here:
http://docs.oracle.com/javase/tutorial/essential/environment/paths.html
After that you can simple go to the directory your source code is in and use the same commands as under linux to compile and run your application.
How to compile and run Java Eclipse Project from command prompt?
How to run a Java Eclipse project from Command Line with java file name only. I don't want to to use class file or jar files generated by Eclipse.
Is it possible?
Even with jar file, I found loading of static file was failing, as FileNotFoundException, how to solve that?
I meant to run like this-
http://www.skylit.com/javamethods/faqs/javaindos.html
First javac then java
Kind of old question I know, but if you want to know command prompt for running Eclipse-based project (i.e the one that Eclipse uses)
Run your project into Eclipse
Goto Debug perspective
(on my screen anyway) Window in top left corner should have a little
'debug' tab.
Right click on name of your project, select Properties at
the bottom of drop-down
Click on the 'Command Line' field (this is what you
probably want).
Press [ctrl]+A & [ctrl]+C to select and copy
Either paste this into command line, or
(what I did) in Windows, create new *.bat text file and paste it in
there ... now double clicking on that file should run your java proj.
Pretty useful if you wanna run something out of eclipse and are lazy like me.
BTW I needed this for exporting project for a uni assignment. Of course, they wanted to see code in *.java files too and above just uses *.class files Eclipse builds on the fly.
To make batch compile your *.java files & then run you need to put together an appropriate javac command before the javaw line you got from process above and adjust accordingly - look at Java Docs for this. Eclipse has done most of hard work with library class paths though (I was using a few libs).
For building you can export an Ant build file. Just right click on the project -> Export -> Ant buildfiles. On the command promt use ant <buildfile> to build the project.
Take a look at this answer: Eclipse: export running configuration for running the eclipse project from the console.
Assumes a project with the following directory structure:
PROJECT_HOME
-> lib (jar files)
-> src (java code)
-> hirondelle (top-level package; no .java files)
-> ante (.java files)
-> deluvian (.java files)
Compiling With javac
PROJECT_HOME>javac -cp lib\* src\hirondelle\ante\*.java src\hirondelle\ante\deluvian\*.java
This compiles in place, and creates .class files beside .java files. If you want to place generated class files elsewhere, use the -d option to put them into an existing directory:
PROJECT_HOME>javac -cp lib\* -d build src\hirondelle\ante\*.java src\hirondelle\ante\deluvian\*.java
If your jars are in various directories, then the classpath is a list delimited by semi-colons:
-cp lib\*;C:\abc\one.jar;C:\xyz\two.jar
For more information refer below links:
Compiling With javac - javapractices
Build Eclipse Java Project from Command Line - Stackoverflow
Select the project and click on File->Export which opens a new window.
From that select Runnablejar option and click next button.
In launch configuration select your main class and in export destination give the path where you want to store the jar file.
I have been researching this for weeks and can't seem to get it figured out.
I have a Java program that I have written using NetBeans. It has several imports or .jar files it relies on. It runs fine in NetBeans. But I can't figure out how to call the .jar files and compile from the bash command line. I am using a Mac. I have read several posts on this and none so far have made sense to me. There are 26 imports being used in the program. I don't know if I need to use Ant or specify -CP or Classpath to compile. Surely I don't have to type each one of the .jar files out to compile this from the bash command line?
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
You should be able to simply use ant with the build.xml in the Netbeans project directory. It should "just work" for you. The project will likely not build WITHOUT Netbeans installed (if you tried moving the project to a different machine, for example), but with Netbeans, it should work out of the box.
If you don't have Ant installed, you'll need to install it.
Addenda:
To build it, if you have Ant installed, you should be able to simply go the project directory, where the build.xml file is, and type "ant", and it should build and put stuff in the dist directory.
If you go in to the dist directory and type java -jar yourapp.jar, it should run, because the manifest in the jar will point to the nearby lib jar files. If you want to distribute the app, there are different options for java, such as making a Mac compatible application, or a Windows EXE, you'll need to search for those. Or you can simply distribute the contents of the dist directory and write a script to do that whole java -jar yourapp.jar command.
If you are using Java 1.6 or above, you can toss all 26 jar files into a folder and simply add
-cp folder_name/*
as your classpath argument.
Some other options are 1.) type all 26 jar files on the command line (using the -cp argument as you have mentioned) 2.) use Ant or Maven or some other build tool and list those 26 jar files in the config file for said build tool or 3.) write a quick-and-dirty shell script that will set the CLASSPATH environment variable for you and then run your javac command.