As a newbie to programming, I am finding it really quite difficult to install all the necessary software and such to get everything running.
Up until now I have been using the command prompt and javac along with gedit to edit/compile my code, but we are meant to be using eclipse and then JUnit to test it.
I have just managed to get eclipse working, but still stuck as to how to get JUnit working.
I am stuck on the installation part...
The JUnit FAQ (http://junit.sourceforge.net/doc/faq/faq.htm#started_1) states...
Windows
To install JUnit on Windows, follow these steps:
Unzip the junit.zip distribution file to a directory referred to as %JUNIT_HOME%.
Add JUnit to the classpath:
set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar
How can you "unzip" the "junit.zip distribution file" to the directory "%JUNIT_HOME%" and how do you add something to the classpath? Where is this class path? I tried extracting the zip folder and typing "%JUNIT_HOME%" into the directory, but it says the destination path is invalid, so I assume this is not what the instructions mean.
Apologies for the noob-questions... I'm finding this technical jargon difficult to find my way around.
Any hints for the next steps for installing JUnit will also be appreciated, as I will likely get stuck on those too.
If you are using Eclipse, please import the junit.jar file to your classpath in your project. You can do it by right+click on the project and choose Properties -> Java Build Path. and add you jar file.
Related
I want to work with some audio analysis and want to use the Phash perceptual algorithm. Here's a Java implementation I want to use.
I'm having trouble adding this project as a dependency; I don't see how to run mvn package test install to get this project linked.
Similarly, this project needs this other project to read the audio files. When I try to install the library using the cmake commands I get errors like sndfile.h: No such file or directory. This Stackoverflow answer shows how to install it, but I still get the sndfile.h: No such file or directory error. I'm on a Mac, by the way. I found the sndfile.h file and copied it to the directory, but the build didn't work in the end anyway.
I feel like this isn't the right way to do this and things should "work" after doing the basic install commands listed in the repositories. What am I missing?
I used to work on an IntelliJ project that was started before I started working on it. This project had a configuration that allowed me to generate an EXE file that could easily be sent to windows users.
It would generate a massive EXE file bundled with all the needed JARs of the application, and upon running it the first time, it would silently "install" itself into the AppData folder, as if it were a regular windows setup file, even though the user would not even notice it doing that installation.
I am trying to configure a project in IntelliJ to do the exact same thing, but first I have not been able to output the exe file by selecting "exe" as the Java FX native bundle type. It just generates a .jnlp and .jar file. When I select "all", as per some other post here in stackoverflow, it generates an exe file, but only with a few kb in size, which does not contain any of the .jar files that should be part of it. Moreover, when I try to open it, it just crashes saying the main class was not found.
Am I missing some setting for building the project? I am using IntelliJ 2018.3.2
Here are some screenshots:
I have been able to get past this error, after changing the verbosity of the compilation and going through the logs.
There was a log message which helped fixing this:
The process complained about the Inno Setup Compiler missing, which was right. Makes me wonder why IntelliJ would have that feature built in if it depends on external tools but does not notify the user clearly of this.
Detected [iscc.exe] version 0.0 but version 5.0 is required.
After going to the Inno Setup site, downloading and installing the tool, I was able to get the executable to be generated.
Now I am struggling with another error, which is the executable complaining about the main class referenced in the Artifact not being found, but at least I have moved past the first problem! Going to tackle this one now...
The best solution for this is using exe generator software.
There is plenty of exe generators out there.
EXE4J is the most simple & easy tool to use.
In EXE4J,
You can upload your main jar file and select the main class.
I think this will be solved your problem.
This may be due to you`ve extracted Jars to your output root, while you neet to Put it(you can check difference by deleting everything from your output root in Output Layout screen and then just right click on jar on the right side, you will see two options here, try another one
I just can't seem to find the .class files for my Groovy source code in IntelliJ IDEA Grails projekt. I've created a grails app "qotd" and a plugin "selenium" which is kind of a grails app itself, as you might know. So just to keep things tidy here's a screenshot of my Grails View:
Grails View
As you can see I have source code for both Java and Groovy. Both share the same package "de.it2m.testcases". Could this be a problem? Anyway, now I need to know where the .class files are stored. I've compiled both the "qotd" app and its "selenium" plugin using the "grails run-app" command without errors, so I'm sure there must be the .class files somewhere. I already found the class file for the "SeGridTest.java" class in:
...IntelliJ workspace\qotd\out\production\selenium-inplacePlugin\de\it2m\testcases
Unfortunately the "SeleniumTest.class" is missing in this directory (as I would have expected it there). I was browsing the ".grails" directory as well but without any success.
Where could the SeleniumTest.class hide...?
Note: I'm working on Windows 8.1 Pro, IntelliJ ultimate 13.1.4 and Grails 2.3.8
#Tinku Saini
Thanks for your help! The .class files get into the "target" directory
I've been working on a project in eclipse for a while and now I need to export it as a JAR file so that I can transfer it to other computers and share it with the people I am working with.
Having never exported anything as a jar before, I googled how to export a jar file and followed the instructions and finally exported. However, whenever I do this (I have tried exporting my project multiple times before asking a question here), I always get the message that my classes have been exported with compile warnings.
Additionally, when I try to launch the jar file, I get a message that it cannot be launched. I have tried everything I can think of to get the jar to export and I have looked at a lot of different questions looking for a solution to my problem, but I can't seem to find one. I'm at my wits end, and if anyone could give me a way to fix this problem, I would be very grateful.
Thanks for the help!
Copy your jar somewhere else on your computer and check if it is working fine.
It might be because of depending classes. To overcome this, add your additional jars when you compile your jar using eclipse to have a little big jar: File -> Export -> Java -> Runnable JAR File -> (then choose) Package required library.... option.
Also, when you deliver your jar, you may ask your client to run CMD (for windows) and then check "Java -jar {your jar file name}" to see what is going on there on their computer.
This is my first question, so apologies for any mistakes. I'll try and give all the info I can. Basically I've written a simple swing application which just loads in image into a JPanel and displays it. I'm using Netbeans 7.1 and I have the latest version of the Java SDK.
Anyway, I've used the "Build" feature in NetBeans 7.1 to deploy my application into a Jar file. When I double click the Jar File on my PC, it runs without a problem. However when I put it on other computers (Tested on 2 others so far, both with the most current JRE) it fails to open, citing the following error:
could not find the main class: swong.Startup. Program will exit
swong is my package name, and Startup is the location of my main method. I have checked the manifest file which is created with Netbeans' build, and it[the manifest] does indeed contain the location of my main method class.
From searching, I've come across similar issues in which the classpath is set wrongly, but I don't understand how this could cause my particular error.
If someone could help me, I would be over the moon. I've been studying java for a year or so, and I've got a good handle down, but I've NEVER been able to make a Jar that runs on a computer which wasn't my own. So, 10 points and thanks in advance.
xo.
EDIT: Thank you for the responses. I'm doing shift work and swamped, but I will test and poke with these responses tomorrow and provide more information. Thanks again. xo
I had d same problem while distributing my app. There is 1 solution that you create a batch file with 'java -jar AppName.jar' and asking user to double click on this batch file to execute your app. What i did was to provide a JRE installation exe(eg: jre_1.7.0) with your app.
Now create a Batch file (install.bat) in which write following commands
jre_1.7.0 -> this will install jre on user's pc
set path="C\Program Files\Java\jre_1.7.0\bin"
java -jar yourAppName.jar
Why i installed JRE because different people have different JRE versions installed. So this makes it difficult to set path to the installed JRE's bin folder & calling the 'java -jar' command. Hence as you know which folders your JRE installation will create hence it is easy to set path and execute your jar file with 'java-jar' command.
Check that your jar file has the following structure (at least)
jarfile.jar
|---------- swong
|---------- Startup.class
|---------- META-INF
|---------- MANIFEST.MF
It seems like the class "Startup" is missing. Maybe your jar only contains the .java files, not the compiled classes.
This error message can be a mistakable java7 error, when you try to start java7 compiled classes with a different Java Runtime Environment then java7. Have you validated, that your .jar is started within a Java7 environment on those other test machines? Sometimes it happens, that you have installed different versions of JREs and you might not be sure which one is actually started.
To check which enviroment is used, you can check in your registry for the following value:
HKEY_CLASSES_ROOT\jarfile\shell\open\command
this should point to your latest JRE. Or if you'd like to stay compatible to java6 as well, define the appropiate compile level in your build environment.