SoapUI: how to include Java file (not Jar file) from external file - java

similar to "SoapUI: How to include Groovy script from an external file"
how can I import/include .java files in groovy step (not .jar file). The reason we want this is because if we create .jar and loose code somehow, any updates are very much problematic.
Thanks in advance.
using open source version of soapui

Since Java is 99% source compatible with Groovy, you could just rename your .java files to .groovy and the follow the instructions from your linked post.

Related

.classpath file in Java related to Java or Eclipse [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have read many sites and then decided to ask this question on stackoverflow, question is pretty basic
What is .classpath file? Is this file related to the Java project or Eclipse?
Some people think that this file related to Eclipse and some thinks that it is related to project?
.class files are related to Java.
You write your code in java, it is compiled by javac into bytecode. The bytecode is stored in the .class files, and further interpreted by the Java virtual machine (JVM).
About .classpath on Wikipedia:
Similar to the classic dynamic loading behavior, when executing Java programs, the Java Virtual Machine finds and loads classes lazily (it loads the bytecode of a class only when this class is first used). The .classpath tells Java where to look in the file-system for files defining these classes.
So the .classpath mechanism is related to Java, and is handled by eclipse thanks to the .classpath file.
Hope it helps :)
It's java bytecode in .class file. Whenever you compile the javacode, you will get .class file per java class. Behind the scenes, Eclipse incrementally does compile your java code in the project and hence you don't end up manually compiling our java code.
The .classpath file is Eclipse's way to keep track of a project's classpath and other build related settings. If you right click on your project and go to Java Build Path, those are the things that are saved in the .classpath file.
The .classpath file is maintained by Eclipse's JDT . JDT holds multiple such "meta" files in the project (see the .settings directory inside the project); the .classpath file is just one of them. Specifically, the .classpath file contains information that the JDT feature needs in order to properly compile the project: the project's source folders (that is, what to compile); the output folders (where to compile to); and classpath entries (such as other projects in the workspace, arbitrary JAR files on the file system, and so forth).
From the wiki
Java class file is a file (with the .class filename extension) containing a Java bytecode which can be executed on the Java Virtual Machine (JVM).
Java class file is produced by Java compiler from Java programming language source files (.java files) containing Java classes.
If a source file has more than one class, each class is compiled into a separate class file.
I can say .classpath is a file required/related only if you are running java project in the eclipse.
Explanation:
You may need some jar file required to run your project, so in this case you have to include these jars in your classpath in order to run your project/application. If you are running manually you have to include jars to classpath and then execute, but if you are using Eclipse this classpath information i.e. the jars that needs to be added will be there in the .classpath file so that you need not add jars manually to the classpath.
NOTE: .classpath file will be automatically generated by the eclipse, this will have the information of the jars you added in you eclipse build path.

Load obfuscated Java code to Eclipse failed because Windows is case-insensitive

all. I am cracking a java software, it's a jar package. I want to decompile it and load its source to Eclipse, so I can analyze it. My Environment is Windows.
I used Java Decompiler to get the source zip from the jar package. Because the jar file is obfuscated, the zip file contains many files like a.java, A.java, Km.java, km.java... in the same folder (or package in java). Zip supports case-sensitive, but Windows does not. When I load the zip to a Eclipse project, the "no-matter-case-same" files get replaced (such as A.java is replaced by a.java), because Eclipse works on the Windows file system.
I don't want to change to linux, I hope there's a Windows solution?
First, it is very, very bad to crack software. So, you are a bad guy.
Second, I'd suggest you to try to run from zip. Configure your project to be dependent on your jar file, store decompiled sources in jar file too and add this jar as a source attachment. This should work.
But better solution is just leave windows ASAP and never return to it.

How to edit library source files on NetBeans?

I am doing JAVA project based on the SSJ (Stochastic Simulation in Java) libraries. In my project I have followed the required steps to import the SSJ library files and also the source files.
When looking at the SSJ library files in the project's Libraries branch, only class files appear shown, but when I open them I can view the source code (which I couldn't before, as I hadn't imported the sources) so I assume everything was imported correctly.
When I run the examples provided with the library everything runs fine and as expected. But if I try to change the source code for the libraries for instance, changing the text on an output, the changes I make to the source files aren't reflected in the output from the java programs.
Any hint on what I might be doing wrong?
I understand this might be hard to understand or test as I can't quite create and SSCCE for this matter. The library files are hosted here (http://www.iro.umontreal.ca/~simardr/ssj/ssj-20120216.zip) and the source code here (http://www.iro.umontreal.ca/~simardr/ssj/ssj-source.html).
Thanks in advance for all your help!
Adding source to libraries it's for debugging and documentation purposes. It does not mean that Netbeans will detect changes and recompile classes automatically.
You should create a project for the library itself to recreate it from source. Changes are that if you have the source there will be a build.xmlor a pom.xml that contains the steps to compile the library and will allow to create a Java Free Form Project or a Project with existing POM.
You'd then remove the reference to library itself and add a dependency to the project.
Other option would be to add the library source to the same project you are using (and, again, removing reference to the library) but I would not recommend this unless it's a very small simple library.
EDIT. Particular ssj information.
ssj is a library where the original source code is in .tex files and it requires several programs available to generate .java files and then compile them. All this information can be found in the COMPILE.txt original file.
Since the source distribution includes .java files it is possible to generate a .jar just using Netbeans but it requires to modify the build.xml to just compile Java source files. Also when creating the Java Free Form Project is necessary to select lib as the target to Build Project.
Here it's a minimal build xml for Netbeans 7.1 to compile from Java sources.
In order to create the new *.java file from the *.tex file, you need the tcode.jar which is available in the distribution. Have you added tcode.jar as an external jar to your project?
umontreal.iro.lecuyer.tcode.Texjava is in tcode.jar

Get back my java source code from .war file?

I recently lost my netbeans project folder of the project that I was working on at the time. However somewhere on a server here at the company that I work at, I deployed it. So that means that I (hopefully) can still get hold of the .war file.
Is it possible to then 'unpack' this .war and get my .java source files back that I was working on at the time?
Thanks in advance!
If the .java sources aren't in the WAR (and they should not be), you'll have to take the additional step of decompiling them using a tool like JAD.
This is a good time to set up a version control system, like Subversion or Git or Mercurial, so this never happens to you again. Get into the habit of using source code management, even if you're the sole developer working on the project.
Short answer: No.
Slightly longer answer: Look for Java decompilers, but they won't give you your Netbeans project folder.
You only get *.class files from your war (rename war to zip and use a decompression tool).
Then you could decompile them.
See this related question for some suggestions.
Suppose if you had exported the source files while creating the war, you can get it. Else, JAD is your only hope that too cannot fully rely on it.
It is possible to unzip the war file where you will get only class files and other property files. Then use Java decompiler to see source code and it works really well (not recommended).
Also you can change the property files without JD and all you need to do just change the property files and zip to war file again.It will work.
But I would recommend you to maintain source code in SVN or TFS or multiple copies with version numbers in local system at any point of time.
In Eclipse, you can Import your War, it will create a new Project and set the resources in the project structure. IF your war holds the source java files, the project will cointain your sources. IF not, the packages will be empty and you will have to manually decompile your classes from bytecode to java files, using jad or another decompiler.

Save files in .jar

I have a couple files I want to include in my .jar for a game server. The files, a SQLite database and an icon, work properly when and only when I put them in the Eclipse project folder and run it straight from Eclipse. As I want this to be distributable to end-users easily, how can I include these files and use them at runtime? Thanks in advance!
Accessing files from within a jar file can be tricky depending on the code that's using them. If the code is written to open a file from the file system, you have to extract it. If your Java code opens it with Class.getResourceAsStream(), it can be read from within the jar. You mentioned an icon and SQLite. I would guess you need to extract those files. I've done this with the maven-dependency-plugin and unpack when using maven. "jar xf foo.jar icon.gif" works too.

Categories