What i do:
1.I am running a scala project,When i added the java source code(java file) in to the project it run
2.I need to add the jar file the project instead of the java source file
3.So i created jar file for the java source file in eclipse and added the jar file in the scala project instead of the java source file
4.But it shows error,when calling the method in the jar file
5.When i added the jar which i created in the java project,it works
Things i need to know:
1.Is there any different ways to add jar(created in java) in the scala project?
2.Whether i need to create jar in any other way?
Related
I am currently using vs code to run my java files.
But when I use coderunner and run my java file it creates a .class file for every class in the same directory of my java file. Which gets messy how can I get rid of that?
I am ok with uninstalling the coderunner but in that case the java file errors doesn't show up properly and build fails.
Uninstall Code Runner and choose Java: Create New Project from Command Palette.
Create a no build tools project and coding in .java files which stored in folder src, then all the generated .class files will be stored in folder bin by default.
About the compilation errors, please post code snippets for further solution.
Install Test Runner for Java or Extension Pack for Java extension both by Microsoft. Better would be to go with an extension pack.
I am new to both Java and to the Eclipse IDE, and I am having trouble with adding a Referenced Library and actually using it in my code.
I am in a software testing class, and my assignment is to use the JWebUnit library to run some basic tests on a website of my choice. I have downloaded a zip of the library and added it to the build path, so that it shows up in my Referenced Libraries list.
When I try to actually use that library, though, the import statement gives an error.
I just cannot figure out what I am doing wrong that the base class cannot see this library.
The screenshot show that you have added the folder net as class folder to the Java Build Path. Maybe you have added the source code (.java files) or Javadoc (.html files) instead of the executable bytecode (.class files). Usually .jar files are provided containing .class files which can directly be added to the Java Build Path.
Probably you want to download e.g. the file jwebunit-3.3-release.zip from here and add all JARs contained in that ZIP (in the root folder and in lib) to your Java Build Path instead.
i'm using eclipse noen and i've created a jar file contains only one java file. but when I added to the application library it still can't be seen.
Can you post the strutcture or an example of the contents of the JAR file?
JAR files should contain compiled java classes, not ".java" files.
If you are using Eclipse, create the JAR file by exporting the project.
Reference: https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-33.htm
I write a very simple java program with two classes: Business and Main.
I want to create a jar such that if I email it to someone they can:
run the program (i.e. run the jar)
open the jar to view the source code.
the code can run on mac or windows
I have been using IDEs for so long I have forgotten how to do this.
I am using netbeans 7.x
EDIT:
I found the following way on Netbeans:
properties > packaging > exclude from jar file :: delete **/*.java
But when I try to execute the jar using
java -jar mybusiness.jar
it says
no main manifest attribute, in mybusiness.jar
But note that my jar has a main class. Am I missing a manifest file?
You can export a JAR file that includes the source code using Netbeans:
Right click on the project and select properties
Build -> Packaging
Remove Java files from the excluded files. And select build jar after compiling
It will create the jar file that includes the source code if it successfully compiles.
Well surely an IDE can do this too?. Just make some text files and put the source into them and drag them into the ide's. It's java so it should automatically run on all platforms. I am not sure what the problem is here?
This link explains how do u create manifest file and how do you specify your main class in manifest file as its necessary for executing jar.
I have written a java program that is actually works as a gui to an existing command line program.
so in basic all my program does is Runtime.getRuntime().exec("myprogram parameter");. So I have exported my java source as a executable-jar file by using Eclipse IDE and it is working nice, however I indeed need to include this myprogram.exe to the directory of the generated jar file inorder to work.
Now I am looking for a way to include myprogram.exe inside the jar file so I can keep it bundled as a single file, a method using using Eclipse would be preferred.
You can simply jar it up as an extra resource (like a .css, .properties etc.).
When your Java program runs, extract the .exe using Class.getResourceAsStream() and write it to a temporary directory in order to run it from there (since you can't run it directly from the .jar file).