I would approach these as follows:
For the case where the ".java" is missing, use the normal string matching functions to see if the suffix is ".java" - if not then append the required string. While it may be possible to come up with a regex, it will be very complex as detecting the absence of a prefix is messy (to say the least). The best you can do is to use a regex to find the ".java" suffix and then use your programming language to append what you want if the match fails - but you can do all this with simple string operations far more easily.
To change all but the last "." to "/", try the pattern:
\.(?=.*?\.)
and the replacement string
/
This looks for a literal period that is followed by another one and replaces it with a "/". The last period will not be followed by another one and so will not be replaced. This covers the 2nd case of example #1 as well as example #2.
For example #3 (I assume that the generic match is to present "*." if there is only a single period in the string) use the pattern:
^(\w+\.\w+)$
and replacement string of
*.$1
(You may need to use '\1' or something else to refer to the captured text form match group #1 in the replacement string). If the composition of your filename induces characters that are not in the '\w' class (such as "$" and the like) then you will need to alter these parts.
Each of these regex replacements will need a separate pass as you cannot tell during the replacement part which replacement string to use.
Susan